zzyengineer / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

.Net C# Verbatim String Literals improperly escaped #93

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
C# allows users to use the @ character to mark a string as a string literal ie
//They can change
string a = "C:\\";
//To
string b = @"C:\";

The problem is that when the second option is used, the \" is still treated
as an escape character and any code that follows is highlighted as if it
were still part of the original quote.

What steps will reproduce the problem?
1. Enter     string a = "\\";    to see functioning code...
2. then enter      string b = @"\";   to see that the semicolon is
highlighted as if it were part of an unterminated string.

What is the expected output?  What do you see instead?
Ideally, if the string begins with an @ (at sign) it should not escape
anything within the string:
http://www.yoda.arachsys.com/csharp/strings.html#literals

What version are you using?  On what browser?

Please provide any additional information below.

Original issue reported on code.google.com by Michael....@gmail.com on 29 Sep 2009 at 5:14

GoogleCodeExporter commented 9 years ago
The relevant portion of the grammar seems to be
verbatim-string-literal:
    @"   verbatim -string-literal-charactersopt   "
verbatim-string-literal-characters:
    verbatim-string-literal-character
    verbatim-string-literal-characters   verbatim-string-literal-character
verbatim-string-literal-character:
    single-verbatim-string-literal-character
    quote-escape-sequence
single-verbatim-string-literal-character:
    any character except "
quote-escape-sequence:
    ""

So verbatim string literals can contain embedded newlines, cannot start with 
single
quotes, and end at the first double quote not followed by a double quote.

Either
  /^"(?:[^"]|"")*(?:"|$)/
or
  /^"[\s\S]*?(?:"(?!")|$)/

Original comment by mikesamuel@gmail.com on 2 Oct 2009 at 5:45

GoogleCodeExporter commented 9 years ago
Thank you for taking on the issue and so quickly.

Original comment by Michael....@gmail.com on 2 Oct 2009 at 5:49

GoogleCodeExporter commented 9 years ago
Fixed at revision 83

http://google-code-prettify.googlecode.com/svn/trunk/tests/prettify_test.html#is
sue93

Original comment by mikesamuel@gmail.com on 3 Oct 2009 at 8:50