Skip to content
Browse files

Merge pull request #90 from nirvdrum/short_circuit_string_tokenization

Updated the RegExp to catch Strings earlier in the tokenization process.
  • Loading branch information...
2 parents 465ae0a + 97bdb23 commit 4be2aef4d385aaeb995ff3024534d357dff30d8e @tenderlove committed Oct 2, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/psych/scalar_scanner.rb
View
4 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

0 comments on commit 4be2aef

Please sign in to comment.
Something went wrong with that request. Please try again.