Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(45)

Issue 32099: Fixes bug 996: /*@4*/ style content in strings confuses the module renderer (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
17 years ago by MikeSamuel
Modified:
12 years, 8 months ago
Reviewers:
ihab.awad
CC:
google-caja-discuss_googlegroups.com
Base URL:
http://google-caja.googlecode.com/svn/trunk/
Visibility:
Public.

Description

Issue 996: Refactor rendering pipeline to always pass tokens *and* marks If the original source code contains a comment inside a string, like: var x = '/*@1*/'; it will get cajoled to: var x = ''; which is not a security breach, but is incorrect. This is because the current pipeline uses textual substitution to keep track of file positions as the source passes through. Got rid of textual substition. Before the process looked like (1) Feed tokens to SourceSpanRenderer which forwards them to a delegate renderer along with /*@1*/ comments wherever there is an original file position mark. (2) Find /*@1*/ inside the rendered text, remove it, and build a mapping from output characters to filepositions from the original source. (3) Munge that list to generate the desired debug metadata. Now the process looks like (1) Feed tokens to SourceSpanRenderer which forwards them to a delegate renderer and keeps a list of all non-comment/space tokens with marks inline. (2) Lex the rendered output using JsLexer and match stored tokens with rendered tokens creating a mapping from original source file positions to rendered source positions. (3) Turn that mapping into a mapping of output characters to original source filepositions. (4) Munge as before. I also did a bit of housecleaning: (1) The SideBySideRenderer and TabularSideBySideRenderer were obsoleted by SourceSnippetRenderer. Deleted them. (2) Got rid of unnecessary IOException handler to SourceSpanRenderer since it always renders to a StringBuilder. (3) Got rid of unnecessary output filename parameter since it seems to be unused except in test code. (4) Got rid of now unused breakAfterComment parameter to JsPrettyPrinter and friends. Since we no longer insert comment tokens (which were subsequently removed), the rendered output matches exactly what an unwrapped pretty printer would do. This invalidated the existing unit tests, so please pay special attention to the test goldens.

Patch Set 1 #

Patch Set 2 : Fixes bug 996: /*@4*/ style content in strings confuses the module renderer #

Unified diffs Side-by-side diffs Delta from patch set Stats (+222 lines, -677 lines) Patch
M src/com/google/caja/parser/js/CajoledModule.java View 1 6 chunks +7 lines, -16 lines 0 comments Download
M src/com/google/caja/render/Indenter.java View 1 2 chunks +2 lines, -7 lines 0 comments Download
M src/com/google/caja/render/JsPrettyPrinter.java View 1 3 chunks +1 line, -8 lines 0 comments Download
D src/com/google/caja/render/SideBySideRenderer.java View 1 1 chunk +0 lines, -199 lines 0 comments Download
M src/com/google/caja/render/SourceSpansRenderer.java View 1 8 chunks +140 lines, -113 lines 0 comments Download
D src/com/google/caja/render/TabularSideBySideRenderer.java View 1 1 chunk +0 lines, -221 lines 0 comments Download
M tests/com/google/caja/AllTests.java View 1 2 chunks +0 lines, -2 lines 0 comments Download
M tests/com/google/caja/parser/quasiliteral/testModule.co.js View 1 1 chunk +14 lines, -17 lines 0 comments Download
M tests/com/google/caja/render/OrigSourceRendererTestCase.java View 1 3 chunks +5 lines, -7 lines 0 comments Download
D tests/com/google/caja/render/SideBySideRendererTest.java View 1 1 chunk +0 lines, -41 lines 0 comments Download
M tests/com/google/caja/render/SourceSnippetRendererTest.java View 1 2 chunks +2 lines, -4 lines 0 comments Download
M tests/com/google/caja/render/SourceSpansRendererTest.java View 1 2 chunks +16 lines, -29 lines 0 comments Download
M tests/com/google/caja/render/ssp-golden.txt View 1 1 chunk +20 lines, -10 lines 0 comments Download
M tests/com/google/caja/render/ssp-rewritten-tokens.txt View 1 1 chunk +15 lines, -3 lines 0 comments Download

Messages

Total messages: 1
MikeSamuel
17 years ago (2009-04-02 01:20:37 UTC) #1

          
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b