summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-08-28 10:44:01 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-08-28 10:44:01 -0700
commit5cc91271b400d58a8ca188aa91d2d2f765bf6e3b (patch)
treec84428987c47064f2bb642113fded271f48e9160
parent2cd98a2f5a82028e56afee424375315cd684d02f (diff)
downloadpsych-5cc91271b400d58a8ca188aa91d2d2f765bf6e3b.tar.gz
* ext/psych/lib/psych/scalar_scanner.rb: invalid floats should be
treated as strings. [Fixes GH-156] https://github.com/tenderlove/psych/issues/156 * test/psych/test_string.rb: test for change fixes #156
-rw-r--r--CHANGELOG.rdoc8
-rw-r--r--lib/psych/scalar_scanner.rb2
-rw-r--r--test/psych/test_string.rb5
3 files changed, 14 insertions, 1 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index 0eb3533..d504369 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -1,3 +1,11 @@
+Thu Aug 29 02:40:45 2013 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/scalar_scanner.rb: invalid floats should be
+ treated as strings.
+ [Fixes GH-156] https://github.com/tenderlove/psych/issues/156
+
+ * test/psych/test_string.rb: test for change
+
Sat Jul 6 04:49:38 2013 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/yaml_tree.rb: register time objects so
diff --git a/lib/psych/scalar_scanner.rb b/lib/psych/scalar_scanner.rb
index 7a9bb87..068fc0e 100644
--- a/lib/psych/scalar_scanner.rb
+++ b/lib/psych/scalar_scanner.rb
@@ -95,7 +95,7 @@ module Psych
end
i
when FLOAT
- if string == '.'
+ if string =~ /\A[-+]?\.\Z/
@string_cache[string] = true
string
else
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index 0bdba18..2512bb6 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -15,6 +15,11 @@ module Psych
end
end
+ def test_dash_dot
+ assert_cycle '-.'
+ assert_cycle '+.'
+ end
+
def test_string_subclass_with_anchor
y = Psych.load <<-eoyml
---