@@ -21,7 +21,6 @@ describe('HTML', function() {
21
21
22
22
var handler , start , text , comment ;
23
23
beforeEach ( function ( ) {
24
- text = "" ;
25
24
handler = {
26
25
start : function ( tag , attrs , unary ) {
27
26
start = {
@@ -36,7 +35,7 @@ describe('HTML', function() {
36
35
} ) ;
37
36
} ,
38
37
chars : function ( text_ ) {
39
- text + = text_ ;
38
+ text = text_ ;
40
39
} ,
41
40
end :function ( tag ) {
42
41
expect ( tag ) . toEqual ( start . tag ) ;
@@ -82,31 +81,8 @@ describe('HTML', function() {
82
81
expect ( text ) . toEqual ( 'text' ) ;
83
82
} ) ;
84
83
85
- it ( 'should not treat "<" followed by a non-/ or non-letter as a tag' , function ( ) {
86
- expectHTML ( '<- text1 text2 <1 text1 text2 <{' , handler ) .
87
- toBe ( '<- text1 text2 <1 text1 text2 <{' ) ;
88
- } ) ;
89
-
90
- it ( 'should throw badparse if text content contains "<" followed by "/" without matching ">"' , function ( ) {
91
- expect ( function ( ) {
92
- htmlParser ( 'foo </ bar' , handler ) ;
93
- } ) . toThrowMinErr ( '$sanitize' , 'badparse' , 'The sanitizer was unable to parse the following block of html: </ bar' ) ;
94
- } ) ;
95
-
96
- it ( 'should throw badparse if text content contains "<" followed by an ASCII letter without matching ">"' , function ( ) {
97
- expect ( function ( ) {
98
- htmlParser ( 'foo <a bar' , handler ) ;
99
- } ) . toThrowMinErr ( '$sanitize' , 'badparse' , 'The sanitizer was unable to parse the following block of html: <a bar' ) ;
100
- } ) ;
101
-
102
- it ( 'should accept tag delimiters such as "<" inside real tags' , function ( ) {
103
- // Assert that the < is part of the text node content, and not part of a tag name.
104
- htmlParser ( '<p> 10 < 100 </p>' , handler ) ;
105
- expect ( text ) . toEqual ( ' 10 < 100 ' ) ;
106
- } ) ;
107
-
108
84
it ( 'should parse newlines in tags' , function ( ) {
109
- htmlParser ( '<tag\ n attr="value"\n>text</\ntag\n>' , handler ) ;
85
+ htmlParser ( '<\ntag\ n attr="value"\n>text<\n /\ntag\n>' , handler ) ;
110
86
expect ( start ) . toEqual ( { tag :'tag' , attrs :{ attr :'value' } , unary :false } ) ;
111
87
expect ( text ) . toEqual ( 'text' ) ;
112
88
} ) ;
@@ -147,9 +123,8 @@ describe('HTML', function() {
147
123
expectHTML ( 'a<!DocTyPe html>c.' ) . toEqual ( 'ac.' ) ;
148
124
} ) ;
149
125
150
- it ( 'should escape non-start tags' , function ( ) {
151
- expectHTML ( 'a< SCRIPT >A< SCRIPT >evil< / scrIpt >B< / scrIpt >c.' ) .
152
- toBe ( 'a< SCRIPT >A< SCRIPT >evil< / scrIpt >B< / scrIpt >c.' ) ;
126
+ it ( 'should remove nested script' , function ( ) {
127
+ expectHTML ( 'a< SCRIPT >A< SCRIPT >evil< / scrIpt >B< / scrIpt >c.' ) . toEqual ( 'ac.' ) ;
153
128
} ) ;
154
129
155
130
it ( 'should remove attrs' , function ( ) {
@@ -190,16 +165,14 @@ describe('HTML', function() {
190
165
expectHTML ( everything ) . toEqual ( everything ) ;
191
166
} ) ;
192
167
193
- it ( 'should mangle improper html' , function ( ) {
194
- // This text is encoded more than a real HTML parser would, but it should render the same.
168
+ it ( 'should handle improper html' , function ( ) {
195
169
expectHTML ( '< div rel="</div>" alt=abc dir=\'"\' >text< /div>' ) .
196
- toBe ( '< div rel="" alt=abc dir=\' "\' > text< /div> ') ;
170
+ toEqual ( '< div rel="</div>" alt=" abc" dir=" ""> text< /div> ') ;
197
171
} ) ;
198
172
199
- it ( 'should mangle improper html2' , function ( ) {
200
- // A proper HTML parser would clobber this more in most cases, but it looks reasonable.
173
+ it ( 'should handle improper html2' , function ( ) {
201
174
expectHTML ( '< div rel="</div>" / >' ) .
202
- toBe ( '< div rel="" / >') ;
175
+ toEqual ( '< div rel="</div >"/> ') ;
203
176
} ) ;
204
177
205
178
it ( 'should ignore back slash as escape' , function ( ) {
@@ -222,12 +195,6 @@ describe('HTML', function() {
222
195
expectHTML ( '\na\n' ) . toEqual ( ' a ' ) ;
223
196
} ) ;
224
197
225
- it ( 'should accept tag delimiters such as "<" inside real tags (with nesting)' , function ( ) {
226
- //this is an integrated version of the 'should accept tag delimiters such as "<" inside real tags' test
227
- expectHTML ( '<p> 10 < <span>100</span> </p>' )
228
- . toEqual ( '<p> 10 < <span>100</span> </p>' ) ;
229
- } ) ;
230
-
231
198
describe ( 'htmlSanitizerWriter' , function ( ) {
232
199
/* global htmlSanitizeWriter: false */
233
200
if ( angular . isUndefined ( window . htmlSanitizeWriter ) ) return ;
0 commit comments