Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more escape runes to be skipped over when parsing string literal. #2734

Merged

Conversation

hoonmin
Copy link
Contributor

@hoonmin hoonmin commented Nov 7, 2018

This PR makes Dgraph to allow more escape runes to be skipped over when parsing string literal.

  • \v
  • \xnn

Description

Hi. I'm trying to upgrade Dgraph to 1.0.10 for HasFunction improvement.
But when bulk-load exported RDF files, we'd got following errors.

2018/11/07 12:41:02 while lexing <_:uid1234> <text> "I'm\x02\vAlice"^^<xs:string> .: Invalid escape character : 'v' in literal
while parsing line "..."
github.com/dgraph-io/dgraph/dgraph/cmd/bulk.(*mapper).processRDF
        /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/bulk/mapper.go:188
github.com/dgraph-io/dgraph/dgraph/cmd/bulk.(*mapper).run
        /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/bulk/mapper.go:135
github.com/dgraph-io/dgraph/dgraph/cmd/bulk.(*loader).mapStage.func1
        /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/bulk/loader.go:237
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1333

And found that lexLiteral function in state.go validates the escape characters.

if r == '\u005c' { // backslash
    r = l.Next()
    if l.IsEscChar(r) || lex.HasUChars(r, l) {
        continue // This would skip over the escaped rune.
    }
    return l.Errorf("Invalid escape character : '%c' in literal", r)
}

Currently Dgraph allows [tbnrf] characters for escaped runes, but I think 'v' should be added like strconv.
https://golang.org/src/strconv/quote.go

Also, there are chances to store \xnn form of HEX values just like \u or \U.
Actually our Dgraph server have stored them but it doesn't allow \xnn when retrieving.

Please check this out. Thanks!


This change is Reviewable

@CLAassistant
Copy link

CLAassistant commented Nov 7, 2018

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. :lgtm_strong:

Reviewable status: 0 of 4 files reviewed, all discussions resolved

@manishrjain manishrjain merged commit 70e07e8 into dgraph-io:master Nov 9, 2018
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants