Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript quotes missing #9892

Closed
manu0401 opened this issue Feb 19, 2025 · 4 comments
Closed

Javascript quotes missing #9892

manu0401 opened this issue Feb 19, 2025 · 4 comments
Labels

Comments

@manu0401
Copy link
Contributor

Describe the bug
Home page (and many others) contains the following JS code:
var avideoModalIframeFullScreenCloseButton = <button type="button" id="avideoModalIframeFullScreenCloseButton" (...)

The string is not quoted and this cause parse errors. Fixing it is hard, because it contains both simple quotes and double quotes. A missed attempt was done in view/include/head.php by wrapping the getHamburgerButton() call by json_encode(). This cannot work because getHamburgerButton() outputs the code instead of returning it.

I have not yet found a reasonably intrusive way of fixing this. I am willing to help, but this requires maintainer insight.

To Reproduce

  1. Load the home page
  2. View sources
  3. Search avideoModalIframeFullScreenCloseButton
  4. See how badly defined it is

Expected behavior
avideoModalIframeFullScreenCloseButton value should be double-quoted and the inner quotes should be properly escaped.

Error Logs
Browser console says:
Uncaught SyntaxError: expected expression, got '<'

Screenshots
None

Desktop (please complete the following information):
All

Smartphone (please complete the following information):
All

Additional context
None

@manu0401 manu0401 added the bug label Feb 19, 2025
@DanielnetoDotCom
Copy link
Member

can you please put the link for the page that is generating this errors?

@manu0401
Copy link
Contributor Author

Right, I got it: the _ob wrappers require php-zlib for ob_gzhandler(), and they silently fail if it is absent.

So far I identified the following required modules: php-mysqli, php-mbstring, php-gd, php-zlib. The installer could look for them in the Check list. If you are okay with that, I can craft a patch.

@Maikuolan
Copy link
Contributor

Fixing it is hard, because it contains both simple quotes and double quotes.

It should be possible to resolve that difficulty by escaping the existing quotes first. For example, let's say we have some JavaScript which tries to define a variable, but is missing some necessary quotes, like this:

var some_variable = Hello there. The cat said "Meow". The dog said "Woof". She's here. He's there. Blah blah blah.

We could fix it like this:

var some_variable = "Hello there. The cat said \"Meow\". The dog said \"Woof\". She's here. He's there. Blah blah blah."

Or like this (depending on whether single or double quotes are preferred in whatever the relevant context is):

var some_variable = 'Hello there. The cat said "Meow". The dog said "Woof". She\'s here. He\'s there. Blah blah blah.'

@manu0401
Copy link
Contributor Author

Bottom line: php-zlib is required, and strange bugs like this one appear if it is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants