wandenberg / nginx-push-stream-module

A pure stream http push technology for your Nginx setup. Comet made easy and really scalable.
Other
2.22k stars 295 forks source link

Replace < with equivalent html entity #183

Closed msurguy closed 9 years ago

msurguy commented 9 years ago

This will prevent the script from breaking since </script makes browsers think that this is the end of the whole script, thus rendering anything after the script closing tag as plain HTML instead.

wandenberg commented 9 years ago

Which browser did you figure out this problem? On May 21, 2015 23:42, "Maksim Surguy" notifications@github.com wrote:

This will prevent the script from breaking since </script makes browsers think that this is the end of the whole script, thus rendering anything

after the script closing tag as plain HTML instead.

You can view, comment on, or merge this pull request online at:

https://github.com/wandenberg/nginx-push-stream-module/pull/183 Commit Summary

  • Replace < with equivalent html entity

File Changes

Patch Links:

— Reply to this email directly or view it on GitHub https://github.com/wandenberg/nginx-push-stream-module/pull/183.

msurguy commented 9 years ago

I am seeing this in Chrome (latest version, Mac OS) and on Safari mobile iOS (iOS 7).

wandenberg commented 9 years ago

Can you send me a step by step with how to reproduce the problem?

msurguy commented 9 years ago

@wandenberg yes. If the current JS script is placed inside of "body" tag of an iFrame. For example if you try to demo your app on Bootsnipp.com or on Codepen.io: http://bootsnipp.com/snippets/55WAX (using current JS) vs http://bootsnipp.com/snippets/lWjP0 (using my updated JS), http://codepen.io/msurguy/pen/ZGyoeJ (using current JS) vs http://codepen.io/msurguy/pen/doRevw (using the last method in this comment).

Here's the explanation why use that instead: http://stackoverflow.com/questions/8231048/why-use-x3c-instead-of-when-generating-html-from-javascript

Another alternative is to break up the string with JS in the following manner:

transferDoc.write("<"+"html>"+"<"+"script>document.domain='" + document.domain + "';"+"<"+"/script>"+"<"+"body>"+"<"+"iframe id='" + this.iframeId + "' src='" + url + "'>"+"<"+"/iframe>"+"<"+"/body>"+"<"+"/html>");
msurguy commented 9 years ago

Thanks @wandenberg !