namhnguyen / asterixdb

Automatically exported from code.google.com/p/asterixdb
0 stars 0 forks source link

Character escaping in AQL #748

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
While escaping of quotes works:

{ "user" : "a\"" } returns { "user": "a\"" }
{ "user" : 'a\'' } returns { "user": "a'" }

there is no way to put a single backslash into a string literal.

{ "user": "a\" } returns { "user": "a\\" }
{ "user" : "a\\" } returns { "user": "a\\\\" }

Original issue reported on code.google.com by westm...@gmail.com on 29 Mar 2014 at 3:46

GoogleCodeExporter commented 9 years ago
The JSON escapes are

\"
\\
\/
\b
\f
\n
\r
\t
\u four-hex-digits

Original comment by westm...@gmail.com on 30 Mar 2014 at 2:04

GoogleCodeExporter commented 9 years ago
The Java escapes are:

EscapeSequence:
   \ b    /* \u0008: backspace BS */
   \ t    /* \u0009: horizontal tab HT */
   \ n    /* \u000a: linefeed LF */
   \ f    /* \u000c: form feed FF */
   \ r    /* \u000d: carriage return CR */
   \ "    /* \u0022: double quote " */
   \ '    /* \u0027: single quote ' */
   \ \              /* \u005c: backslash \ */
   OctalEscape        /* \u0000 to \u00ff: from octal value */

OctalEscape:
   \ OctalDigit
   \ OctalDigit OctalDigit
   \ ZeroToThree OctalDigit OctalDigit

OctalDigit: one of
   0 1 2 3 4 5 6 7

ZeroToThree: one of
   0 1 2 3

Original comment by westm...@gmail.com on 30 Mar 2014 at 2:04

GoogleCodeExporter commented 9 years ago
In AQL we currently only escape \" in "-delimited strings and \' in '-delimited 
strings.

Original comment by westm...@gmail.com on 30 Mar 2014 at 2:05

GoogleCodeExporter commented 9 years ago
There's a patch in branch westmann/issue748 that introduces an escape sequence 
for \.
With this
  { "user": "a\" } returns a lexical error and
  { "user" : "a\\" } returns { "user": "a\\" }

The open question is, if we should also support other escape sequences 
(analogously to JSON?) in string literals in AQL or if this minimal approach is 
better.

Original comment by westm...@gmail.com on 31 Mar 2014 at 5:32

GoogleCodeExporter commented 9 years ago
The review for this change is now at http://codereview.appspot.com/84580043

Original comment by westm...@gmail.com on 4 Apr 2014 at 4:24

GoogleCodeExporter commented 9 years ago

Original comment by westm...@gmail.com on 4 Apr 2014 at 4:25

GoogleCodeExporter commented 9 years ago

Original comment by westm...@gmail.com on 4 Apr 2014 at 7:03

GoogleCodeExporter commented 9 years ago
This is extended by issue 753.

Original comment by ker...@gmail.com on 4 Apr 2014 at 9:15

GoogleCodeExporter commented 9 years ago

Original comment by westm...@gmail.com on 4 Apr 2014 at 9:26

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Could you verify that it works?

Original comment by westm...@gmail.com on 4 Apr 2014 at 9:35