HTML output was broken when authors with quotes were sent to JavaScript.

Fixed by using json.dumps() to escape the author name before passing it to
the JavaScript output.
This commit is contained in:
Adam Waldenberg 2015-09-08 01:35:42 +02:00
parent 98c375a0ab
commit 124ca74650
2 changed files with 4 additions and 2 deletions

View file

@ -29,6 +29,7 @@ import filtering
import format
import gravatar
import interval
import json
import multiprocessing
import re
import subprocess
@ -246,7 +247,7 @@ class BlameOutput(Outputable):
blame_xml += "<td>" + "{0:.2f}".format(100.0 * entry[1].comments / entry[1].rows) + "</td>"
blame_xml += "<td style=\"display: none\">" + work_percentage + "</td>"
blame_xml += "</tr>"
chart_data += "{{label: \"{0}\", data: {1}}}".format(entry[0], work_percentage)
chart_data += "{{label: {0}, data: {1}}}".format(json.dumps(entry[0]), work_percentage)
if blames[-1] != entry:
chart_data += ", "

View file

@ -28,6 +28,7 @@ import filtering
import format
import gravatar
import interval
import json
import os
import subprocess
import terminal
@ -238,7 +239,7 @@ class ChangesOutput(Outputable):
changes_xml += "<td>" + str(authorinfo.deletions) + "</td>"
changes_xml += "<td>" + "{0:.2f}".format(percentage) + "</td>"
changes_xml += "</tr>"
chart_data += "{{label: \"{0}\", data: {1}}}".format(entry, "{0:.2f}".format(percentage))
chart_data += "{{label: {0}, data: {1}}}".format(json.dumps(entry), "{0:.2f}".format(percentage))
if sorted(authorinfo_list)[-1] != entry:
chart_data += ", "