Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 29761597: Issue 6538, 6781 - Implement script parsing for snippets (Closed)

Created:
April 25, 2018, 5:25 p.m. by Manish Jethani
Modified:
July 17, 2018, 3:25 p.m.
Reviewers:
Sebastian Noack, kzar
CC:
sergei, hub, erikvvold
Base URL:
https://hg.adblockplus.org/adblockpluscore/
Visibility:
Public.

Description

This builds on https://codereview.adblockplus.org/29737558/

Patch Set 1 #

Total comments: 4

Patch Set 2 : Move parseScript to top level #

Patch Set 3 : Support single character escape sequences #

Patch Set 4 : Support Unicode escape sequences #

Total comments: 1

Patch Set 5 : Rebase #

Total comments: 13

Patch Set 6 : Move singleCharacterEscapes to outer scope #

Patch Set 7 : Rename literal to withinQuotes #

Patch Set 8 : Add some comments #

Total comments: 3

Patch Set 9 : Revert Patch Set 8 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+142 lines, -1 line) Patch
M lib/snippets.js View 1 2 3 4 5 6 8 2 chunks +78 lines, -0 lines 0 comments Download
M test/snippets.js View 1 2 3 4 2 chunks +64 lines, -1 line 0 comments Download

Messages

Total messages: 20
Manish Jethani
April 25, 2018, 5:25 p.m. (2018-04-25 17:25:39 UTC) #1
Manish Jethani
Patch Set 1 This builds on https://codereview.adblockplus.org/29737558/ See issue description for specification.
April 26, 2018, 12:22 p.m. (2018-04-26 12:22:53 UTC) #2
Manish Jethani
https://codereview.adblockplus.org/29761597/diff/29761598/lib/snippets.js File lib/snippets.js (right): https://codereview.adblockplus.org/29761597/diff/29761598/lib/snippets.js#newcode83 lib/snippets.js:83: * @return {Array.<string[]>} I had to use Array.<string[]> instead ...
April 26, 2018, 1:25 p.m. (2018-04-26 13:25:17 UTC) #3
Manish Jethani
https://codereview.adblockplus.org/29761597/diff/29761598/test/snippets.js File test/snippets.js (right): https://codereview.adblockplus.org/29761597/diff/29761598/test/snippets.js#newcode152 test/snippets.js:152: checkParsedScript("Script with argument containing an escaped space", Also note ...
April 26, 2018, 1:27 p.m. (2018-04-26 13:27:34 UTC) #4
Manish Jethani
Patch Set 3: Support single character escape sequences Since filters can't contain non-space whitespace because ...
April 26, 2018, 3:36 p.m. (2018-04-26 15:36:39 UTC) #5
Manish Jethani
On 2018/04/26 15:36:39, Manish Jethani wrote: > Patch Set 3: Support single character escape sequences ...
April 26, 2018, 3:45 p.m. (2018-04-26 15:45:12 UTC) #6
Manish Jethani
Patch Set 4: Support Unicode escape sequences Now you can write a filter like "example.com#$#foo ...
April 26, 2018, 4:22 p.m. (2018-04-26 16:22:09 UTC) #7
Manish Jethani
On 2018/04/26 16:22:09, Manish Jethani wrote: > Patch Set 4: Support Unicode escape sequences > ...
April 26, 2018, 4:23 p.m. (2018-04-26 16:23:16 UTC) #8
Manish Jethani
Patch Set 5: Rebase
May 23, 2018, 4:14 a.m. (2018-05-23 04:14:28 UTC) #9
kzar
Copying in Erik and Sebastian since I think as many people as possible should review ...
July 10, 2018, 1:55 p.m. (2018-07-10 13:55:21 UTC) #10
Manish Jethani
On 2018/07/10 13:55:21, kzar wrote: > Copying in Erik and Sebastian since I think as ...
July 11, 2018, 1:19 p.m. (2018-07-11 13:19:30 UTC) #11
Manish Jethani
Patch Set 6: Move singleCharacterEscapes to outer scope https://codereview.adblockplus.org/29761597/diff/29787583/lib/snippets.js File lib/snippets.js (right): https://codereview.adblockplus.org/29761597/diff/29787583/lib/snippets.js#newcode84 lib/snippets.js:84: function ...
July 11, 2018, 7:04 p.m. (2018-07-11 19:04:42 UTC) #12
Manish Jethani
Patch Set 7: Rename literal to withinQuotes Patch Set 8: Add some comments
July 12, 2018, 8:37 a.m. (2018-07-12 08:37:36 UTC) #13
kzar
Once you remove those extra comments this LGTM. I would like someone (ideally Sebastian) to ...
July 12, 2018, 10:30 a.m. (2018-07-12 10:30:37 UTC) #14
Manish Jethani
Patch Set 9: Revert Patch Set 8 On 2018/07/12 10:30:37, kzar wrote: > Once you ...
July 12, 2018, 10:57 a.m. (2018-07-12 10:57:49 UTC) #15
Sebastian Noack
I wonder if the implementation would be simpler (and more robust) if we'd just handle ...
July 16, 2018, 4:28 p.m. (2018-07-16 16:28:05 UTC) #16
Manish Jethani
On 2018/07/16 16:28:05, Sebastian Noack wrote: > I wonder if the implementation would be simpler ...
July 17, 2018, 10:47 a.m. (2018-07-17 10:47:23 UTC) #17
Sebastian Noack
On 2018/07/17 10:47:23, Manish Jethani wrote: > On 2018/07/16 16:28:05, Sebastian Noack wrote: > > ...
July 17, 2018, 12:24 p.m. (2018-07-17 12:24:13 UTC) #18
Manish Jethani
On 2018/07/17 12:24:13, Sebastian Noack wrote: > On 2018/07/17 10:47:23, Manish Jethani wrote: > > ...
July 17, 2018, 12:50 p.m. (2018-07-17 12:50:10 UTC) #19
Sebastian Noack
July 17, 2018, 2:56 p.m. (2018-07-17 14:56:26 UTC) #20
On 2018/07/17 12:50:10, Manish Jethani wrote:
> If you're suggesting that every argument, after adding the surrounding quotes,
> could be parsed as a JSON string, that somewhat makes sense.

Yes, this what I'm suggesting.

> But in order to
> extract the arguments we would still have to go through the entire script,
> character by character. If we're going to do that, we might as well do the
> parsing of the arguments based on our own spec?
> 
> There is more to JSON strings [1] than what we need in a snippet filter. JSON
is
> more strict. For example, a sole "\x" is an error, whereas in our spec we
simply
> treat it as an "x". We are more forgiving in what input we accept, which is
how
> it should be, since this is not a programming language and is going to be used
> by non-programmers (so it's more like HTML than JavaScript).
> 
> One more good reason not to implement JSON is that we're going to have to port
> this to C++ at some point and it would be really nice if we did not have the
> overhead of JSON.

Fair enough, LGTM.

Powered by Google App Engine
This is Rietveld