Skip to content

Commit 6b773c0

Browse files
committed
whitelist floats with exponents in YAML
fixes CNVS-26342 test plan: * have a quiz submission with an absurdly small score (like 1e-15); I have no idea how to produce this * loading speedgrader for that quiz should work Change-Id: Icc7a73ab61d2517661824b828fb2a73f115a097e Reviewed-on: https://gerrit.instructure.com/70024 Tested-by: Jenkins Reviewed-by: Ethan Vizitei <evizitei@instructure.com> QA-Review: August Thornton <august@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
1 parent 8a53495 commit 6b773c0

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

lib/canvas_yaml.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def merge_into_hash(hash, array)
4949
whitelisted_tags: %w[
5050
tag:ruby.yaml.org,2002:symbol
5151
tag:yaml.org,2002:float
52+
tag:yaml.org,2002:float#exp
5253
tag:yaml.org,2002:str
5354
tag:yaml.org,2002:timestamp
5455
tag:yaml.org,2002:timestamp#iso8601

spec/lib/safe_yaml_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
b: 2
4646
float: !float
4747
5.1
48+
float_with_exp: -1.7763568394002505e-15
4849
os: !ruby/object:OpenStruct
4950
modifiable: true
5051
table:
@@ -105,6 +106,9 @@ def verify(result, key, klass)
105106
float = verify(result, 'float', Float)
106107
expect(float).to eq 5.1
107108

109+
float_with_exp = verify(result, 'float_with_exp', Float)
110+
expect(float_with_exp).to eq(-1.7763568394002505e-15)
111+
108112
os = verify(result, 'os', OpenStruct)
109113
expect(os.a).to eq 1
110114
expect(os.b).to eq 2

0 commit comments

Comments
 (0)