Merge pull request #1727 from yuce/allow-backslash-cr-in-pql-strings

fix double escapes
This commit is contained in:
Yuce Tekol 2018-11-07 01:25:59 +03:00 • committed by GitHub
commit 2416d7a4c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 315 additions and 303 deletions

View file

@ -75,7 +75,7 @@ func TestParser_Parse(t *testing.T) {
// Parse with only arguments.
t.Run("ArgumentsOnly", func(t *testing.T) {
q, err := pql.ParseString(`MyCall( key= value, foo='bar', age = 12 , bool0=true, bool1=false, x=null, escape="\" \\escape\n" )`)
q, err := pql.ParseString(`MyCall( key= value, foo='bar', age = 12 , bool0=true, bool1=false, x=null, escape="\" \\escape\n\\\\" )`)
if err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(q.Calls[0],
@ -88,7 +88,7 @@ func TestParser_Parse(t *testing.T) {
"bool0": true,
"bool1": false,
"x": nil,
"escape": "\" \\escape\n",
"escape": "\" \\escape\n\\\\",
},
},
) {

View file

@ -49,8 +49,8 @@ item <- ( 'null' &(comma / sp close) { p.addVal(nil) }
/ '\'' < singlequotedstring > '\'' { p.addVal(buffer[begin:end]) }
)
doublequotedstring <- ( '\\\"' / [^"] )*
singlequotedstring <- ( '\\\'' / [^'] )*
doublequotedstring <- ( '\\"' / '\\\\' / [^"] )*
singlequotedstring <- ( '\\\'' / '\\\\' / [^'] )*
fieldExpr <- [[A-Z]] ( [[A-Z]] / [0-9] / '_' / '-' )*
field <- <fieldExpr / reserved> { p.addField(buffer[begin:end]) }

File diff suppressed because it is too large Load diff