Merge "Refactored and cleaned up Sanitizer + bug fix."

This commit is contained in:
GWicke 2012-07-30 17:59:48 +00:00 committed by Gerrit Code Review
commit d19bebabde
2 changed files with 615 additions and 642 deletions

File diff suppressed because it is too large Load diff

View file

@ -64,8 +64,8 @@ var Util = {
* @returns {Boolean}: True if token is block-level, false otherwise.
*/
isBlockToken: function ( token ) {
if ( token.constructor === TagTk ||
token.constructor === EndTagTk ||
if ( token.constructor === TagTk ||
token.constructor === EndTagTk ||
token.constructor === SelfclosingTagTk ) {
return Util.isBlockTag( token.name.toLowerCase() );
} else {
@ -279,9 +279,32 @@ var Util = {
} else {
return text;
}
},
arrayToHash: function(a) {
var h = {};
for (var i = 0, n = a.length; i < n; i++) {
h[a[i]] = 1;
}
return h;
},
// Returns the utf8 encoding of the code point
codepointToUtf8: function(cp) {
return unescape(encodeURIComponent(cp));
},
// Returns true if a given Unicode codepoint is a valid character in XML.
validateCodepoint: function(cp) {
return (cp === 0x09) ||
(cp === 0x0a) ||
(cp === 0x0d) ||
(cp >= 0x20 && cp <= 0xd7ff) ||
(cp >= 0xe000 && cp <= 0xfffd) ||
(cp >= 0x10000 && cp <= 0x10ffff);
}
};
if (typeof module == "object") {
if (typeof module === "object") {
module.exports.Util = Util;
}