aboutsummaryrefslogtreecommitdiffstats
path: root/test/sanitizerSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2011-01-19 15:42:11 -0800
committerMisko Hevery2011-01-24 14:23:51 -0800
commitc2f2587a79aeb77aad66f081cf924a79348a698e (patch)
tree8f5aa4cc6e7189befb834388b2102d1eda88a975 /test/sanitizerSpec.js
parent5d0d34ae72a9ca47f1b2dabda60711ad16ee9313 (diff)
downloadangular.js-c2f2587a79aeb77aad66f081cf924a79348a698e.tar.bz2
fixed example rendering, add tests for it.
Diffstat (limited to 'test/sanitizerSpec.js')
-rw-r--r--test/sanitizerSpec.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/test/sanitizerSpec.js b/test/sanitizerSpec.js
index 3ad6c1c9..57eedec9 100644
--- a/test/sanitizerSpec.js
+++ b/test/sanitizerSpec.js
@@ -50,11 +50,11 @@ describe('HTML', function(){
});
it('should handle entities', function(){
- var everything = '<div rel="!@#$%^&amp;*()_+-={}[]:&#34;;\'&lt;&gt;?,./`~ &#295;">' +
+ var everything = '<div rel="!@#$%^&amp;*()_+-={}[]:&#34;;\'&lt;&gt;?,./`~ &#295;">' +
'!@#$%^&amp;*()_+-={}[]:&#34;;\'&lt;&gt;?,./`~ &#295;</div>';
expectHTML(everything).toEqual(everything);
});
-
+
it('should handle improper html', function(){
expectHTML('< div rel="</div>" alt=abc dir=\'"\' >text< /div>').
toEqual('<div rel="&lt;/div&gt;" alt="abc" dir="&#34;">text</div>');
@@ -64,19 +64,19 @@ describe('HTML', function(){
expectHTML('< div rel="</div>" / >').
toEqual('<div rel="&lt;/div&gt;"/>');
});
-
+
it('should ignore back slash as escape', function(){
expectHTML('<img alt="xxx\\" title="><script>....">').
toEqual('<img alt="xxx\\" title="&gt;&lt;script&gt;...."/>');
});
-
+
it('should ignore object attributes', function(){
expectHTML('<a constructor="hola">:)</a>').
toEqual('<a>:)</a>');
expectHTML('<constructor constructor="hola">:)</constructor>').
toEqual('');
});
-
+
describe('htmlSanitizerWriter', function(){
var writer, html;
beforeEach(function(){
@@ -118,13 +118,13 @@ describe('HTML', function(){
writer.start('div', {unknown:""});
expect(html).toEqual('<div>');
});
-
+
describe('explicitly dissallow', function(){
it('should not allow attributes', function(){
writer.start('div', {id:'a', name:'a', style:'a'});
expect(html).toEqual('<div>');
});
-
+
it('should not allow tags', function(){
function tag(name) {
writer.start(name, {});
@@ -149,13 +149,13 @@ describe('HTML', function(){
expect(html).toEqual('');
});
});
-
+
describe('isUri', function(){
-
+
function isUri(value) {
return value.match(URI_REGEXP);
}
-
+
it('should be URI', function(){
expect(isUri('http://abc')).toBeTruthy();
expect(isUri('https://abc')).toBeTruthy();
@@ -163,7 +163,7 @@ describe('HTML', function(){
expect(isUri('mailto:me@example.com')).toBeTruthy();
expect(isUri('#anchor')).toBeTruthy();
});
-
+
it('should not be UIR', function(){
expect(isUri('')).toBeFalsy();
expect(isUri('javascript:alert')).toBeFalsy();