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

update expression escape #3580

Merged
merged 11 commits into from
Mar 23, 2020
Merged

update expression escape #3580

merged 11 commits into from
Mar 23, 2020

Conversation

Danieladu
Copy link
Collaborator

@Danieladu Danieladu commented Mar 17, 2020

close: #3510
update Expression escape policy to make expression achieve higher robustness.

the new strategy of expression evaluation about escape characters is as below:

  • in any case, \n, \r, \t, \\ would be unescaped.
  • In double quotation mark string, \" would be unescaped. There is no need to escape `and ' in double quotation mark string
  • In single quotation marks string, \' would be unescaped. There is no need to escape ` and " in single quotation mark string
  • in string interpolation mode, \` and \$ would be unescaped
  • other characters that have \ prefix, would leave it as is
    samples:
expression result description
`hi\`` hi` support ` escape in string interpolation
`\${a}` ${a} escape $ in string interpolation
"ab\"cd" ab"cd escape " in double quot string
'ab\'cd' ab'cd escape ' in single quot string
"ab`cd" ab`cd no need to escape ` in normal string(' or ")
"ab\ncd" ab [newline] cd newline would be unescaped
`hi\y` hi\y unrecognized escape character would not be unescaped
"ab\ycd" ab\ycd unrecognized escape character would not be unescaped

@Danieladu Danieladu added LG R9 Release 9 - May 15th, 2020 labels Mar 17, 2020
@boydc2014
Copy link
Contributor

should we throw error when the escape is not valid? if user want \, they should use \\

@boydc2014
Copy link
Contributor

should we throw error when the escape is not valid? if user want \, they should use \\

Actually not, we should not throw, because user will not aware of this error until runtime, we should tolerant that. So your implementation make sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R9 Release 9 - May 15th, 2020
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support escape quotation marks in expression string
2 participants