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

Avoid double-decoding on attribute value #4797

Merged
merged 2 commits into from
Jan 31, 2017
Merged

Avoid double-decoding on attribute value #4797

merged 2 commits into from
Jan 31, 2017

Conversation

jddxf
Copy link
Contributor

@jddxf jddxf commented Jan 27, 2017

Chained replaces here may cause problems if the order isn't carefully arranged.Currently we get " after decoding " while " is expected.

For a quick fix, I could move the replace which replaces &s to the last.However, I prefer one single replace so that we don't bother with chaining order.

…ding issue,i.e. get `"` after decoding `"` while `"` is expected.
.replace(gtRE, '>')
.replace(ampRE, '&')
.replace(quoteRE, '"')
const re = shouldDecodeNewlines ? /&(lt|gt|quot|amp|#10);/g : /&(lt|gt|quot|amp);/g
Copy link
Member

Choose a reason for hiding this comment

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

Can we hoist the two RegExps out so that they don't get instantiated on every call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense!

@yyx990803
Copy link
Member

Good catch!

@jddxf
Copy link
Contributor Author

jddxf commented Jan 27, 2017

It took me one hour to come up with the variable names:sob:

@yyx990803 yyx990803 merged commit d14bd64 into vuejs:dev Jan 31, 2017
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request head (fix-attr-decoding@9e539b6).


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af1ec1b...9e539b6. Read the comment docs.

@jddxf jddxf deleted the fix-attr-decoding branch April 30, 2017 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants