Skip to content

Commit

Permalink
[opt-viewer] HTML-escape function names
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293869 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
anemet committed Feb 2, 2017
1 parent 73efe1f commit 77d2e86
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/opt-viewer/opt-viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from pygments import highlight
from pygments.lexers.c_cpp import CppLexer
from pygments.formatters import HtmlFormatter
import cgi

p = subprocess.Popen(['c++filt', '-n'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
p_lock = Lock()
Expand Down Expand Up @@ -103,7 +104,7 @@ def getArgString(self, mapping):
(key, value) = mapping.items()[0]

if key == 'Caller' or key == 'Callee':
value = demangle(value)
value = cgi.escape(demangle(value))

if dl and key != 'Caller':
return "<a href={}>{}</a>".format(
Expand Down Expand Up @@ -207,6 +208,7 @@ def render_inline_remarks(self, r, line):
# replace everything else with spaces.
indent = line[:r.Column - 1]
indent = re.sub('\S', ' ', indent)

print('''
<tr>
<td></td>
Expand Down Expand Up @@ -254,11 +256,12 @@ def __init__(self, output_dir):
self.stream = open(os.path.join(output_dir, 'index.html'), 'w')

def render_entry(self, r, odd):
escaped_name = cgi.escape(r.DemangledFunctionName)
print('''
<tr>
<td class=\"column-entry-{odd}\"><a href={r.Link}>{r.DebugLocString}</a></td>
<td class=\"column-entry-{odd}\">{r.RelativeHotness}</td>
<td class=\"column-entry-{odd}\">{r.DemangledFunctionName}</td>
<td class=\"column-entry-{odd}\">{escaped_name}</td>
<td class=\"column-entry-{r.color}\">{r.Pass}</td>
</tr>'''.format(**locals()), file=self.stream)

Expand Down

0 comments on commit 77d2e86

Please sign in to comment.