From 97bdb23e260c9b2245c27877e5d81736b2ee41da Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 2 Oct 2012 11:40:00 -0400 Subject: [PATCH] Updated the RegExp to catch Strings earlier in the tokenization process. --- lib/psych/scalar_scanner.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/psych/scalar_scanner.rb b/lib/psych/scalar_scanner.rb index ce4b7670..91307463 100644 --- a/lib/psych/scalar_scanner.rb +++ b/lib/psych/scalar_scanner.rb @@ -24,7 +24,9 @@ def tokenize string return string if @string_cache.key?(string) case string - when /^[A-Za-z_~]/ + # Check for a String type, being careful not to get caught by hash keys, hex values, and + # special floats (e.g., -.inf). + when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/ if string.length > 5 @string_cache[string] = true return string