-
Notifications
You must be signed in to change notification settings - Fork 59
Fix unified expression language single quote escape #125
Conversation
@50Wliu could you review this pull request? Thanks! |
@MoritzKn May I ask for your input here? Do you need to double-escape backslashes in EL? |
@50Wliu I haven't used it for quite some time and don't have a setup at hand to test it right now. The specification says:
-- http://download.oracle.com/otn-pub/jcp/jsp-2.1-fr-spec-oth-JSpec/jsp-2_1-fr-spec-el.pdf However this may not apply for this case since it's embedded in the JSP code. |
My hunch is that since this is embedded in JSP, we should be adding escape character support to JSP instead of EL. |
The reason I fixed in EL was due to broken My understanding is that JSP file is for tags and attributes (key = value), and values are parsed as EL (scope |
From the "Quoting and Escape Conventions" section of http://download.oracle.com/otn-pub/jcp/jsp-2_3-mrel2-eval-spec/JSP2.3MR.pdf?AuthParam=1517623843_d412f1e03b76e1d552dbf301b0948086 (not sure how up-to-date that is), backslash escaping is done in attribute values (in this case EL). So I think what's happening here is the same thing as what's happening when writing grammar files - the backslash needs to be double-escaped once for EL and then the second time for JSP. |
@50Wliu I think this is what we do - escape only |
@sadikovi No, I believe that we should add proper escape tokenization to the JSP language. |
@50Wliu thanks for the review and comment! I used previous escape scope as a guidance and thought that this fox should be there as well. I am going to close this PR - currently there are other more critical issues to fix:) |
Requirements
Description of the Change
This PR fixes issue when escaping single quote in single quoted string affects subsequent highlighting, because current pattern matches the first single quote as the end of the literal, even though it is escaped. It was realised that we only need to match ending of literal when it is not escaped, any single quote with preceding '\' should be marked as escaped.
Before patch:
After patch:
Also correctly highlights situation
'\\ '
, though I am not sure if this is a correct syntax.Alternate Designs
None were considered apart from the PR solution.
Benefits
Fixes issue of highlighting when escaping single quote in single quote string literal.
Possible Drawbacks
Might break some other code, because I am not very familiar with expression language and could have overlooked some escape situations, such as using the
\\'
as a value.Applicable Issues
Fixes #83