A simple document.write implementation that uses the sax parser in the HTML sanitizer, and the element/attribute sanitizing code from DOMita's attribute sanitizer.
Submitted @3802
http://codereview.appspot.com/130076/diff/19/23 File src/com/google/caja/plugin/html-emitter.js (right): http://codereview.appspot.com/130076/diff/19/23#newcode220 Line 220: var isLimitClosed = detached[0].parentNode !== limit; Good point. ...
16 years, 5 months ago
(2009-10-15 20:19:52 UTC)
#6
http://codereview.appspot.com/130076/diff/19/23
File src/com/google/caja/plugin/html-emitter.js (right):
http://codereview.appspot.com/130076/diff/19/23#newcode220
Line 220: var isLimitClosed = detached[0].parentNode !== limit;
Good point. Done
http://codereview.appspot.com/130076/diff/19/23#newcode290
Line 290: var eltype = html4.ELEMENTS[tagName];
On 2009/10/15 19:39:59, felix8a wrote:
> need hasOwnProperty test here
Done.
http://codereview.appspot.com/130076/diff/19/23#newcode291
Line 291: if ((eltype & html4.eflags.UNSAFE) !== 0) { return; }
On 2009/10/15 19:39:59, felix8a wrote:
> it looks to me like if a startTag is rejected, the matching endTag will never
> find the right tag to close, so it will close all open tags, screwing up the
> rest of the structure. which is ok, but should be documented.
I don't think it will. endTag never changes the insertionPoint unless it finds
a match.
http://codereview.appspot.com/130076/diff/19/23#newcode291
Line 291: if ((eltype & html4.eflags.UNSAFE) !== 0) { return; }
On 2009/10/15 19:39:59, felix8a wrote:
> it also looks like this doesn't cope too well with optional-close, like <p>.
> which is ok, but should also be documented.
Fixed. If the element type is optional, and the top is an element of the same
type, then this will bump up one level.
That should handle <p>'s and <li>'s and <td>'s closing each other, but will not
address the problem of an <h1> closing a <p>. To do that, we'd need to keep
track of what are block level elements, or allowed containment relationships.
http://codereview.appspot.com/130076/diff/19/23#newcode351
Line 351: ___.grantRead(tameDoc, 'writeln');
On 2009/10/15 19:39:59, felix8a wrote:
> shouldn't this be grantFunc?
>
Done.
http://codereview.appspot.com/130076/diff/19/24 File src/com/google/caja/plugin/domita.js (right): http://codereview.appspot.com/130076/diff/19/24#newcode799 Line 799: // Swap last attribute name/value pair in place, ...
16 years, 5 months ago
(2009-10-15 20:22:30 UTC)
#7
http://codereview.appspot.com/130076/diff/19/24
File src/com/google/caja/plugin/domita.js (right):
http://codereview.appspot.com/130076/diff/19/24#newcode799
Line 799: // Swap last attribute name/value pair in place, and reprocess here.
On 2009/10/15 19:39:59, felix8a wrote:
> I'm wary that you're changing the order of the attributes, which matters if an
> attribute is duplicated, but iirc browsers aren't consistent about what value
> gets used when an attr is repeated, so it shouldn't matter. maybe add a
comment
> about that.
Done.
http://codereview.appspot.com/130076/diff/19/23 File src/com/google/caja/plugin/html-emitter.js (right): http://codereview.appspot.com/130076/diff/19/23#newcode291 Line 291: if ((eltype & html4.eflags.UNSAFE) !== 0) { return; ...
16 years, 5 months ago
(2009-10-15 20:23:45 UTC)
#8
http://codereview.appspot.com/130076/diff/19/23
File src/com/google/caja/plugin/html-emitter.js (right):
http://codereview.appspot.com/130076/diff/19/23#newcode291
Line 291: if ((eltype & html4.eflags.UNSAFE) !== 0) { return; }
On 2009/10/15 20:19:52, MikeSamuel wrote:
> On 2009/10/15 19:39:59, felix8a wrote:
> > it looks to me like if a startTag is rejected, the matching endTag will
never
> > find the right tag to close, so it will close all open tags, screwing up the
> > rest of the structure. which is ok, but should be documented.
>
> I don't think it will. endTag never changes the insertionPoint unless it
finds
> a match.
>
oh, right. I was misreading that.
Issue 130076: Issue 1102: document.write support for DOMita
(Closed)
Created 16 years, 5 months ago by MikeSamuel
Modified 16 years, 5 months ago
Reviewers: metaweta, felix8a
Base URL: http://google-caja.googlecode.com/svn/trunk/
Comments: 21