Question

I'm trying to fix the following issue, as it's being very annoying on my site. https://code.google.com/p/google-code-prettify/issues/detail?id=341&thanks=341&ts=1398085413

and refers to the following file of the prettify code: https://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-sql.js?r=179

The issue is that

  1. When in SQL creating a string that ends with a "\", the highlighter thinks it is escaped, while this is not T-SQL syntax.
  2. To reproduce, use this code as source code: (with Google Code Prettify installed)

    <pre class="prettyprint lang-sql">
     SELECT @BUPath = 'c:\backups\' + @DBName + '-B4 CHANGE.bak'
     SELECT @BUName = @DBName + '-B4 CHANGE'
    </pre>
    

I would expect the code to understand that the slash before the quote in the part 'c:\backups\' is not an escaping character...

I am expecting that this line would need to be changed, but I am not sure how:

[PR['PR_STRING'],      /^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/, null,
      '"\'']

fiddle showing the issue: http://jsfiddle.net/JH5uj/5/

Était-ce utile?

La solution

I think the PR_STRING definition at https://github.com/google/code-prettify/blob/master/src/lang-sql.js must have been copied from some other language where backslash is an escape character.

/^(?:"[^"]*"|'[^']*')/

does it as far as I can tell, but being a mere database guy I could be missing something.

(Sorry to be late to the party with this, but I just hit the same issue and found this thread.)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top