File tree 2 files changed +35
-2
lines changed
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ angular.module('neo4jApp.directives')
36
36
json2html = (obj ) ->
37
37
return emptyMarker () unless Object .keys (obj).length
38
38
html = " <table class='json-object'><tbody>"
39
- html += " <tr><th>#{ k } </th><td>#{ cell2html (v)} </td></tr>" for own k, v of obj
39
+ html += " <tr><th>#{ Utils . escapeHTML (k) } </th><td>#{ cell2html (v)} </td></tr>" for own k, v of obj
40
40
html += " </tbody></table>"
41
41
html
42
42
@@ -62,7 +62,7 @@ angular.module('neo4jApp.directives')
62
62
html = " <table class='table data'>"
63
63
html += " <thead><tr>"
64
64
for col in cols
65
- html += " <th>#{ col} </th>"
65
+ html += " <th>#{ Utils . escapeHTML ( col) } </th>"
66
66
html += " </tr></thead>"
67
67
html += " <tbody>"
68
68
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