graphql 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/enum_type.rb +1 -1
- data/lib/graphql/language/lexer.rb +3 -1
- data/lib/graphql/language/lexer.rl +3 -1
- data/lib/graphql/version.rb +1 -1
- data/spec/graphql/enum_type_spec.rb +4 -0
- data/spec/graphql/language/lexer_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f79f91876d8a49ea48c4d551a073491c33eefc31
|
4
|
+
data.tar.gz: 3e91b2b21c60df562e95879a4a8fd24f214553e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86a409aedbc0f2261b80b1f4cbca9e5fcc529abdb609557299de5547ff554e5f98a35188dcf6ba1a82650995f8989d867738c98aeafda4de7686b33932dff371
|
7
|
+
data.tar.gz: 23135beccd828141bb898bd12514899a0125035f38284146f2941a36e5117449854759e6b202937996e078782123e7f87437f5244be6af392186fd8d1d798cdc
|
data/lib/graphql/enum_type.rb
CHANGED
@@ -104,7 +104,7 @@ module GraphQL
|
|
104
104
|
matching_value = allowed_values.find { |v| v.name == value_name }
|
105
105
|
|
106
106
|
if matching_value.nil?
|
107
|
-
result.add_problem("Expected #{JSON.generate(value_name, quirks_mode: true)} to be one of: #{allowed_values.join(', ')}")
|
107
|
+
result.add_problem("Expected #{JSON.generate(value_name, quirks_mode: true)} to be one of: #{allowed_values.map(&:name).join(', ')}")
|
108
108
|
end
|
109
109
|
|
110
110
|
result
|
@@ -1029,9 +1029,11 @@ end
|
|
1029
1029
|
UTF_8 = /\\u[\dAa-f]{4}/i
|
1030
1030
|
UTF_8_REPLACE = ->(m) { [m[-4..-1].to_i(16)].pack('U'.freeze) }
|
1031
1031
|
|
1032
|
+
VALID_STRING = /\A(?:[^\\]|#{ESCAPES}|#{UTF_8})*\z/o
|
1033
|
+
|
1032
1034
|
def self.emit_string(ts, te, meta)
|
1033
1035
|
value = meta[:data][ts...te].pack("c*").force_encoding("UTF-8")
|
1034
|
-
if value
|
1036
|
+
if value !~ VALID_STRING
|
1035
1037
|
meta[:tokens] << token = GraphQL::Language::Token.new(
|
1036
1038
|
name: :BAD_UNICODE_ESCAPE,
|
1037
1039
|
value: value,
|
@@ -184,9 +184,11 @@ module GraphQL
|
|
184
184
|
UTF_8 = /\\u[\dAa-f]{4}/i
|
185
185
|
UTF_8_REPLACE = ->(m) { [m[-4..-1].to_i(16)].pack('U'.freeze) }
|
186
186
|
|
187
|
+
VALID_STRING = /\A(?:[^\\]|#{ESCAPES}|#{UTF_8})*\z/o
|
188
|
+
|
187
189
|
def self.emit_string(ts, te, meta)
|
188
190
|
value = meta[:data][ts...te].pack("c*").force_encoding("UTF-8")
|
189
|
-
if value
|
191
|
+
if value !~ VALID_STRING
|
190
192
|
meta[:tokens] << token = GraphQL::Language::Token.new(
|
191
193
|
name: :BAD_UNICODE_ESCAPE,
|
192
194
|
value: value,
|
data/lib/graphql/version.rb
CHANGED
@@ -75,6 +75,10 @@ describe GraphQL::EnumType do
|
|
75
75
|
|
76
76
|
it "returns an invalid result" do
|
77
77
|
assert(!result.valid?)
|
78
|
+
assert_equal(
|
79
|
+
result.problems.first['explanation'],
|
80
|
+
"Expected \"bad enum\" to be one of: COW, DONKEY, GOAT, REINDEER, SHEEP, YAK"
|
81
|
+
)
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
@@ -19,6 +19,18 @@ describe GraphQL::Language::Lexer do
|
|
19
19
|
assert_equal tokens[0], tokens[1].prev_token
|
20
20
|
end
|
21
21
|
|
22
|
+
it "unescapes escaped characters" do
|
23
|
+
assert_equal "\" \\ / \b \f \n \r \t", subject.tokenize('"\\" \\\\ \\/ \\b \\f \\n \\r \\t"').first.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
it "unescapes escaped unicode characters" do
|
27
|
+
assert_equal "\t", subject.tokenize('"\\u0009"').first.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
it "rejects bad unicode, even when there's good unicode in the string" do
|
31
|
+
assert_equal :BAD_UNICODE_ESCAPE, subject.tokenize('"\\u0XXF \\u0009"').first.name
|
32
|
+
end
|
33
|
+
|
22
34
|
it "clears the previous_token between runs" do
|
23
35
|
tok_1 = subject.tokenize(query_string)
|
24
36
|
tok_2 = subject.tokenize(query_string)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codeclimate-test-reporter
|