Created
February 20, 2014 23:34
-
-
Save minrk/9125657 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 5deb1504dab0b60de9373c8432dac2fd7d0b0032 Mon Sep 17 00:00:00 2001 | |
From: MinRK <benjaminrk@gmail.com> | |
Date: Thu, 20 Feb 2014 15:33:36 -0800 | |
Subject: [PATCH] log elements removed when unrecognized | |
--- | |
src/com/google/caja/plugin/html-sanitizer.js | 15 ++++++++++----- | |
1 file changed, 10 insertions(+), 5 deletions(-) | |
diff --git a/src/com/google/caja/plugin/html-sanitizer.js b/src/com/google/caja/plugin/html-sanitizer.js | |
index e54053f..e8382a4 100644 | |
--- a/src/com/google/caja/plugin/html-sanitizer.js | |
+++ b/src/com/google/caja/plugin/html-sanitizer.js | |
@@ -661,7 +661,7 @@ var html = (function(html4) { | |
* @return {function(string, Array)} A function that sanitizes a string of | |
* HTML and appends result strings to the second argument, an array. | |
*/ | |
- function makeHtmlSanitizer(tagPolicy) { | |
+ function makeHtmlSanitizer(tagPolicy, opt_logger) { | |
var stack; | |
var ignoring; | |
var emit = function (text, out) { | |
@@ -674,7 +674,12 @@ var html = (function(html4) { | |
}, | |
'startTag': function(tagNameOrig, attribs, out) { | |
if (ignoring) { return; } | |
- if (!html4.ELEMENTS.hasOwnProperty(tagNameOrig)) { return; } | |
+ if (!html4.ELEMENTS.hasOwnProperty(tagNameOrig)) { | |
+ if (opt_logger) { | |
+ log(opt_logger, tagNameOrig, undefined, undefined, undefined); | |
+ } | |
+ return; | |
+ } | |
var eflagsOrig = html4.ELEMENTS[tagNameOrig]; | |
if (eflagsOrig & html4.eflags['FOLDABLE']) { | |
return; | |
@@ -1019,9 +1024,9 @@ var html = (function(html4) { | |
* makeHtmlSanitizer above for details). | |
* @return {string} The sanitized HTML. | |
*/ | |
- function sanitizeWithPolicy(inputHtml, tagPolicy) { | |
+ function sanitizeWithPolicy(inputHtml, tagPolicy, opt_logger) { | |
var outputArray = []; | |
- makeHtmlSanitizer(tagPolicy)(inputHtml, outputArray); | |
+ makeHtmlSanitizer(tagPolicy, opt_logger)(inputHtml, outputArray); | |
return outputArray.join(''); | |
} | |
@@ -1038,7 +1043,7 @@ var html = (function(html4) { | |
opt_naiveUriRewriter, opt_nmTokenPolicy, opt_logger) { | |
var tagPolicy = makeTagPolicy( | |
opt_naiveUriRewriter, opt_nmTokenPolicy, opt_logger); | |
- return sanitizeWithPolicy(inputHtml, tagPolicy); | |
+ return sanitizeWithPolicy(inputHtml, tagPolicy, opt_logger); | |
} | |
// Export both quoted and unquoted names for Closure linkage. | |
-- | |
1.8.5.5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment