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

Fixes escape character sequences that are not on the last attributes #590

Merged
merged 2 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/absinthe_lexer.xrl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ BlockStringValue = """{BlockStringCharacter}*"""
HexDigit = [0-9A-Fa-f]
EscapedUnicode = u{HexDigit}{HexDigit}{HexDigit}{HexDigit}
EscapedCharacter = ["\\\/bfnrt]
StringCharacter = ([^\"{_LineTerminator}]|\\{EscapedUnicode}|\\{EscapedCharacter})
StringCharacter = ([^\\"{_LineTerminator}]|\\{EscapedUnicode}|\\{EscapedCharacter})
StringValue = "{StringCharacter}*"

% Boolean Value
Expand Down
31 changes: 31 additions & 0 deletions test/absinthe/phase/parse/block_strings_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,37 @@ defmodule Absinthe.Phase.Parse.BlockStringsTest do
assert "slashes \\\\ \\/" == extract_body(result)
end

test "parses attributes when there are escapes" do
assert {:ok, result} = run(
~s<{ post(title: "title", body: "body\\\\") { name } }>
)
assert "body\\" == extract_body(result)

assert {:ok, result} = run(
~s<{ post(title: "title\\\\", body: "body") { name } }>
)
assert "body" == extract_body(result)
end

test "parse attributes where there are escapes on multiple lines" do
assert {:ok, result} = run(
~s<{ post(
title: "title",
body: "body\\\\"
) { name } }>
)
assert "body\\" == extract_body(result)

assert {:ok, result} = run(
~s<{ post(
title: "title\\\\",
body: "body"
) { name } }>
)
assert "body" == extract_body(result)
end


@input [
"",
" Hello,",
Expand Down