in Project Network Graph, commit messages are in javascript
but there's interesting special case for escaping </script>
for example if I've such commit message: fixed missing </script>
it will break graph totally
it's because text inside <script> (in HTML) are parsed in specific way and </script> is ending script block and making all next parsed as HTML
(look at "message":"fixed missing </script>")
<script> //<![CDATA[ var chunk1={commits:[{"parents":[["756400df57485ee8df5418628adb404b236fb000",0,0]],"author":"D\u0101vis","time":8,"space":1,"refs":"master","id":"e4dbf8bfc539d46ff33b24f6241cc805608705a6","date":"2012-09-19T16:07:58+00:00","message":"fixed missing </script>","login":"davispuh@local"}]}; var days=[[19,"Sep"]]; initGraph(); $(function(){ branchGraph($("#holder")[0]); initGraphNav(); }); //]]></script>
interesting is that if page would be served as XHTML (XHTML5) this would perfectly work because CDATA wouldn't be parsed at all..
this can be fixed if we escape </script> with <\/script> or even / with \/
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related.
Learn more.
61049424 kinda fix this, but actually not properly, because it introduces new "bug" (or feature :D)
if I make commit with message: expecting <sometag and="attributes"> including </script> :) and then looking at graph it will be fine, but mouseover commit dot I'll see expecting including :), because attributes and some tags are stripped (eg.<b> isn't)
EDIT
here's one funny: <h1>GitLab</h1> is <NOT> bad, <3 it will become <h1>GitLab</h1> is bad, <3 so I think this needs fixing :D
By Administrator on 2012-09-20T07:12:23 (imported from GitLab project)
By Administrator on 2012-09-20T07:12:23 (imported from GitLab)
can't say it's real fix, it's more a workaround, stripping </script> (along with other tags,attributes...) from message doesn't solve real cause, it's actually really tricky place due nature of HTML parser which does parse <script>, but in specific way: ignore everything except </script>
// </script> WTF, not possible to write it even in comment :(console.log("<\/script>");// that's how we can bypass...
with XHTML it's so much easier...
By Administrator on 2012-09-20T07:42:06 (imported from GitLab project)
By Administrator on 2012-09-20T07:42:06 (imported from GitLab)
it does solve it perfectly, maybe it could be solved in different way as that regexp could be considered as a little hack, but it does work way better than any other proposed fix...
any commit messages is shown exactly as it should, including commit messages containing </script>
EDIT
that regexp replaces every </ with <\/ inside double quotes
By Administrator on 2012-09-21T09:00:58 (imported from GitLab project)
By Administrator on 2012-09-21T09:00:58 (imported from GitLab)
Submitted a pull request which resolves this issue, but it's still not ideal, using JSON as JS objects.
So the next step should be; separately load the commit data as JSON after the page has loaded, this would avoid all the in-page escape/entity issues.
By Administrator on 2012-12-05T00:07:56 (imported from GitLab project)
By Administrator on 2012-12-05T00:07:56 (imported from GitLab)
Just updated my PR, the graph now loads the JSON data asynchronously, and the explicit escaping of the HTML is no longer necessary, because to_json already escapes enough.
By Administrator on 2012-12-07T21:15:29 (imported from GitLab project)
By Administrator on 2012-12-07T21:15:29 (imported from GitLab)