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

Uncaught SyntaxError: Unexpected token ILLEGAL causes save to become stuck #3717

Closed
peterfarrell opened this issue Dec 30, 2014 · 12 comments
Closed

Comments

@peterfarrell
Copy link

The following code causes Chrome to break when saving a plugin. The plugin saves and the modal updates with "XXX was changed successfully. You may edit it again below." The modal doesn't redirect and stalls with JS error Uncaught SyntaxError: Unexpected token ILLEGAL

https://github.com/divio/django-cms/blob/e2dfbf86b1a11173bff1dff6285d8d68e0631105/cms/templates/admin/cms/page/close_frame.html#L7-L12

<script>
window.CMS || window.parent.CMS || document.write(
    '<script src="/static/cms/js/libs/jquery.min.js" type="text/javascript"></script>' +
    '<script src="/static/cms/js/modules/cms.base.js" type="text/javascript"></script>'
);
</script>

The error looks like this in Chrome:

image

@yakky yakky added this to the 3.0.10 milestone Feb 7, 2015
@mkoistinen
Copy link
Contributor

I can't seem to reproduce this. Can anyone else? Also, I've inspected the code in the repo for funny symbols, etc., that might cause JS rendering issues, but, didn't find any.

@peterfarrell
Copy link
Author

It's certainly not because of funny symbols being committed but how certain browsers are handling the line of code I indicated. I have over 10 confirmed computers in our company that demonstrate this behavior. My guess it has to do with multiple script tags in a single write.

If I roll back enough, I see it was introduced in this commit:

https://github.com/divio/django-cms/blob/06f89bf4180d30d94d0c55534f7e100eb0fb0292/cms/templates/admin/cms/page/close_frame.html

@peterfarrell
Copy link
Author

@mkoistinen - are you using Chrome on Linux? That is where we are seeing the major of the issues.

@peterfarrell
Copy link
Author

I knew I've seen this before. Here is the issue...

http://stackoverflow.com/a/20737569

The problem is that the string passed to document.write includes the characters </script>, which ends up prematurely terminating the script element that document.write is called from.

The characters </script> can't appear anywhere within a script, since the HTML parser has no way to distinguish this from an actual </script> tag.

Using document.write isn't probably the best solution in this case.

@mkoistinen
Copy link
Contributor

@peterfarrell
Copy link
Author

@mkoistinen just this the 3.0.x version just to double check?

@mkoistinen
Copy link
Contributor

Yes please. Clearly, if this works, it will be merged into both 3.0.10, and the develop branch.

@mkoistinen mkoistinen reopened this Feb 14, 2015
@mkoistinen mkoistinen modified the milestones: 3.1, 3.0.10 Feb 14, 2015
@mkoistinen
Copy link
Contributor

This is now fixed for 3.0.x

@peterfarrell
Copy link
Author

I haven't had a chance to confirm. I will on Monday. Did you reproduce the
issue?
On Feb 14, 2015 8:42 AM, "Martin Koistinen" notifications@github.com
wrote:

Closed #3717 #3717.


Reply to this email directly or view it on GitHub
#3717 (comment).

@mkoistinen
Copy link
Contributor

I was unable to reproduce the issue, but it is clear that this issue was introduced here: 182f17f

@jrief any comment?

@peterfarrell
Copy link
Author

@mkoistinen ... I have tried your fix and I have been unable to repro the issue any more. I believe it has fixed the issue. Thank you for merging.

Do you know when this will hit PIP? Our company policy is to use only stable packages from PIP if possible.

@mkoistinen
Copy link
Contributor

django CMS 3.0.10 was released formally on Saturday, 14th of February, 2015. =) It included this fix.

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

No branches or pull requests

4 participants