Skip to content

Commit ef8fdf8

Browse files
committed
fix(Lexer) don't replace backslash-u with unicode
1 parent 5ee86b3 commit ef8fdf8

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

lib/graphql/compatibility/query_parser_specification.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_it_parses_inputs
5757
int: 3,
5858
float: 4.7e-24,
5959
bool: false,
60-
string: "☀︎🏆\\n escaped \\" unicode \u00b6 /",
60+
string: "☀︎🏆\\n \\" \u00b6 /",
6161
enum: ENUM_NAME,
6262
array: [7, 8, 9]
6363
object: {a: [1,2,3], b: {c: "4"}}
@@ -71,7 +71,7 @@ def test_it_parses_inputs
7171
assert_equal 3, inputs[0].value, "Integers"
7272
assert_equal 0.47e-23, inputs[1].value, "Floats"
7373
assert_equal false, inputs[2].value, "Booleans"
74-
assert_equal %|☀︎🏆\n escaped " unicode ¶ /|, inputs[3].value, "Strings"
74+
assert_equal %|☀︎🏆\n " ¶ /|, inputs[3].value, "Strings"
7575
assert_instance_of GraphQL::Language::Nodes::Enum, inputs[4].value
7676
assert_equal "ENUM_NAME", inputs[4].value.name, "Enums"
7777
assert_equal [7,8,9], inputs[5].value, "Lists"

lib/graphql/language/lexer.rl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ module GraphQL
109109
# To avoid allocating more strings, this modifies the string passed into it
110110
def self.replace_escaped_characters_in_place(raw_string)
111111
raw_string.gsub!(ESCAPES, ESCAPES_REPLACE)
112-
raw_string.gsub!(UTF_8, &UTF_8_REPLACE)
113112
nil
114113
end
115114

@@ -178,9 +177,6 @@ module GraphQL
178177
"\\t" => "\t",
179178
}
180179

181-
UTF_8 = /\\u[\dAa-f]{4}/i
182-
UTF_8_REPLACE = ->(m) { [m[-4..-1].to_i(16)].pack('U'.freeze) }
183-
184180
def self.emit_string(ts, te, meta)
185181
value = meta[:data][ts...te].pack("c*").force_encoding("UTF-8")
186182
if value =~ /\\u|\\./ && value !~ ESCAPES

0 commit comments

Comments
 (0)