{"action":"created","issue":{"url":"https://api.github.com/repos/splitbrain/dokuwiki/issues/1178","labels_url":"https://api.github.com/repos/splitbrain/dokuwiki/issues/1178/labels{/name}","comments_url":"https://api.github.com/repos/splitbrain/dokuwiki/issues/1178/comments","events_url":"https://api.github.com/repos/splitbrain/dokuwiki/issues/1178/events","html_url":"https://github.com/splitbrain/dokuwiki/issues/1178","id":82355035,"number":1178,"title":"CDATA wrapping is problematic for non-JavaScript scripts","user":{"login":"dbfun","id":6669049,"avatar_url":"https://avatars.githubusercontent.com/u/6669049?v=3","gravatar_id":"","url":"https://api.github.com/users/dbfun","html_url":"https://github.com/dbfun","followers_url":"https://api.github.com/users/dbfun/followers","following_url":"https://api.github.com/users/dbfun/following{/other_user}","gists_url":"https://api.github.com/users/dbfun/gists{/gist_id}","starred_url":"https://api.github.com/users/dbfun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbfun/subscriptions","organizations_url":"https://api.github.com/users/dbfun/orgs","repos_url":"https://api.github.com/users/dbfun/repos","events_url":"https://api.github.com/users/dbfun/events{/privacy}","received_events_url":"https://api.github.com/users/dbfun/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/splitbrain/dokuwiki/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/splitbrain/dokuwiki/labels/Category:%20CSS%20XHTML%20JS%20Browsers","name":"Category: CSS XHTML JS Browsers","color":"FFC274"},{"url":"https://api.github.com/repos/splitbrain/dokuwiki/labels/Severity:%20Small","name":"Severity: Small","color":"FAD6C4"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-29T09:40:44Z","updated_at":"2015-06-06T16:52:15Z","closed_at":null,"body":"Hi!\r\n\r\n[This bug fix is fail](https://bugs.dokuwiki.org/index.php?do=details&task_id=2563)\r\n\r\nExplanation: it blocks a normal work of API. \r\n\r\nF.e. [Semantic Action Plugin lines 140-143](https://github.com/LotarProject/dokuwiki-plugin-semantic/blob/master/action.php)\r\n\r\n```\r\n$event->data[\"script\"][] = array (\r\n    \"type\"  => \"application/ld+json\",\r\n    \"_data\" => json_encode($json_ld),\r\n);\r\n```\r\n\r\nwill produce:\r\n\r\n```\r\n<script type=\"application/ld+json\">/*<![CDATA[*/{MY_DATA}\r\n/*!]]>*/</script>\r\n```\r\n\r\nAnd this markup is invalid, plugin not works.\r\n\r\nTo reproduce: \r\n\r\n* install Semantic Action Plugin\r\n* check markup via any validator. I use [this](https://webmaster.yandex.ru/microtest.xml)"},"comment":{"url":"https://api.github.com/repos/splitbrain/dokuwiki/issues/comments/109617248","html_url":"https://github.com/splitbrain/dokuwiki/issues/1178#issuecomment-109617248","issue_url":"https://api.github.com/repos/splitbrain/dokuwiki/issues/1178","id":109617248,"user":{"login":"selfthinker","id":108893,"avatar_url":"https://avatars.githubusercontent.com/u/108893?v=3","gravatar_id":"","url":"https://api.github.com/users/selfthinker","html_url":"https://github.com/selfthinker","followers_url":"https://api.github.com/users/selfthinker/followers","following_url":"https://api.github.com/users/selfthinker/following{/other_user}","gists_url":"https://api.github.com/users/selfthinker/gists{/gist_id}","starred_url":"https://api.github.com/users/selfthinker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selfthinker/subscriptions","organizations_url":"https://api.github.com/users/selfthinker/orgs","repos_url":"https://api.github.com/users/selfthinker/repos","events_url":"https://api.github.com/users/selfthinker/events{/privacy}","received_events_url":"https://api.github.com/users/selfthinker/received_events","type":"User","site_admin":false},"created_at":"2015-06-06T16:52:15Z","updated_at":"2015-06-06T16:52:15Z","body":"I was reading up on this and helped myself remembering things...\r\n\r\nA few facts:\r\n* The CDATA block is needed in XML/XHTML and when there is any `>`, `<` or `&` in the code (or when it is possible to be there), special problem to consider: `</script>` being in the code, see also [differences in how HTML and XML parse raw text elements](http://www.w3.org/TR/html-polyglot/#ambiguous-table)\r\n* The comments around it are needed (in HTML) because just the CDATA itself will be invalid syntax for any script (except XML-based scripts); they are not needed in XML/XHTML (as they wouldn't be part of the script itself)\r\n* But the type of comments obviously depend on the type of script\r\n* Any type of script is allowed inside the script tags in HTML (although only JavaScript is commonly interpreted by browsers)\r\n* Therefore, ideally the syntax for comments around the CDATA blocks should adjust depending on which script language is used\r\n* Special caveat: There are no comments in JSON... that means it's not possible to include JSON in an inline script tag in XML/XHTML (only solution is to make the script external) :(\r\n* And I just learned that content in style tags should also be in CDATA blocks\r\n\r\nSo, solution? ... No idea! Now my head hurts..."}}