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

Lexer is panicking with some weird unicode chars #318

Closed
bnjjj opened this issue Sep 29, 2022 · 1 comment · Fixed by #320 or apollographql/router#1921
Closed

Lexer is panicking with some weird unicode chars #318

bnjjj opened this issue Sep 29, 2022 · 1 comment · Fixed by #320 or apollographql/router#1921
Assignees
Labels
bug Something isn't working

Comments

@bnjjj
Copy link
Contributor

bnjjj commented Sep 29, 2022

Here is a test to reproduce:

#[test]
fn tests_unicode() {
    let gql_1 = "\"\n\n\\u{c}\nPSK\\u{1}\\0\\0\\0י";
    let lexer_1 = Lexer::new(gql_1);
    dbg!(lexer_1.tokens);
    dbg!(lexer_1.errors);
}

it will panic because it doesn't respect char boundary here

@bnjjj bnjjj added bug Something isn't working triage labels Sep 29, 2022
@lrlna lrlna removed the triage label Sep 29, 2022
@lrlna
Copy link
Member

lrlna commented Sep 29, 2022

It panics because one of the (line terminator) characters in that particular string doesn't get added to the Error data, so we end up with an off by one error, which means we can't slice the original input string properly.

As a quick workaround, you may wish to put this string into a raw string: r#"\"\n\n\\u{c}\nPSK\\u{1}\\0\\0\\0י"#. I'll be looking into this bug tomorrow.

lrlna added a commit that referenced this issue Sep 30, 2022
…tors

We were missing adding a line terminator character to the errors created by the lexer in case of a unterminated string. This showed up incidentally while dealing with unicode and the fact that it's of a different byte length than most other characters.

fixes #318
@lrlna lrlna self-assigned this Sep 30, 2022
lrlna added a commit that referenced this issue Sep 30, 2022
…tors (#320)

We were missing adding a line terminator character to the errors created by the lexer in case of a unterminated string. This showed up incidentally while dealing with unicode and the fact that it's of a different byte length than most other characters.

fixes #318

Co-authored-by: Irina Shestak <[email protected]>
SimonSapin pushed a commit to apollographql/router that referenced this issue Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants