Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deobfuscate string cleanup while expanding URLs #13162

Merged
merged 4 commits into from
Feb 1, 2018
Merged

Deobfuscate string cleanup while expanding URLs #13162

merged 4 commits into from
Feb 1, 2018

Conversation

calebcordry
Copy link
Member

@calebcordry calebcordry commented Jan 30, 2018

If a user gives a bad input like REPLACE(vanishing`hello-word`, `-`) the string vanishing will get removed. Instead of swallowing the error we should tell the user.

Open to bike-shedding about the actual warning sentence.

@@ -134,6 +134,9 @@ export class Expander {
if (!ignoringChars) {
ignoringChars = true;
nextArgShouldBeRaw = true;
user().assert(builder === '' || builder === ' ',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builder.trim() === ''

Copy link
Member Author

@calebcordry calebcordry Jan 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think we should allow n number of whitespaces? I was trying to prevent this:

REPLACE(hello-world,                `-`)

edit: github wont let me do it lol. Basically a bunch of whitespace between first and second arg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's currently allowed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@lannka
Copy link
Contributor

lannka commented Jan 31, 2018

can you add a test case?

expect().to.throw()

@calebcordry calebcordry merged commit 6cb7197 into ampproject:master Feb 1, 2018
@calebcordry calebcordry deleted the parser-warn branch February 1, 2018 21:52
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
* Deobfuscate url string cleanup

* Clean up check

* write test

* fix test
protonate pushed a commit to protonate/amphtml that referenced this pull request Mar 15, 2018
* Deobfuscate url string cleanup

* Clean up check

* write test

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants