File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ angular.module('neo4jApp.directives')
35
35
json2html = (obj ) ->
36
36
return emptyMarker () unless Object .keys (obj).length
37
37
html = " <table class='json-object'><tbody>"
38
- html += " <tr><th>#{ k } </th><td>#{ cell2html (v)} </td></tr>" for own k, v of obj
38
+ html += " <tr><th>#{ Utils . escapeHTML (k) } </th><td>#{ cell2html (v)} </td></tr>" for own k, v of obj
39
39
html += " </tbody></table>"
40
40
html
41
41
@@ -59,7 +59,7 @@ angular.module('neo4jApp.directives')
59
59
html = " <table class='table data'>"
60
60
html += " <thead><tr>"
61
61
for col in cols
62
- html += " <th>#{ col} </th>"
62
+ html += " <th>#{ Utils . escapeHTML ( col) } </th>"
63
63
html += " </tr></thead>"
64
64
html += " <tbody>"
65
65
if result .displayedSize
Original file line number Diff line number Diff line change @@ -33,3 +33,36 @@ describe 'Directive: neoTable', () ->
33
33
columns : -> [' col' ]
34
34
scope .$apply ()
35
35
expect (element .html ()).toContain (' <script>' )
36
+
37
+ it ' should escape HTML characters in column name' , inject ($rootScope , $compile ) ->
38
+ scope = $rootScope .$new ()
39
+ element = angular .element ' <neo-table table-data="val"></neo-table>'
40
+ element = $compile (element)(scope)
41
+ scope .val =
42
+ rows : -> [[]]
43
+ displayedSize : 1
44
+ columns : -> [' <p>' ]
45
+ scope .$apply ()
46
+ expect (element .html ()).toContain (' <p>' )
47
+
48
+ it ' should escape HTML characters in property name' , inject ($rootScope , $compile ) ->
49
+ scope = $rootScope .$new ()
50
+ element = angular .element ' <neo-table table-data="val"></neo-table>'
51
+ element = $compile (element)(scope)
52
+ scope .val =
53
+ rows : -> [[{' <p>' : ' value' }]]
54
+ displayedSize : 1
55
+ columns : -> [' col' ]
56
+ scope .$apply ()
57
+ expect (element .html ()).toContain (' <p>' )
58
+
59
+ it ' should escape HTML characters in property value' , inject ($rootScope , $compile ) ->
60
+ scope = $rootScope .$new ()
61
+ element = angular .element ' <neo-table table-data="val"></neo-table>'
62
+ element = $compile (element)(scope)
63
+ scope .val =
64
+ rows : -> [[{' key' : ' <p>' }]]
65
+ displayedSize : 1
66
+ columns : -> [' col' ]
67
+ scope .$apply ()
68
+ expect (element .html ()).toContain (' <p>' )
You can’t perform that action at this time.
0 commit comments