Skip to content

Commit

Permalink
Fix float resolver for '.' and '._'
Browse files Browse the repository at this point in the history
A single dot matches the official YAML 1.1 int regex.
This was probably unintended. The regex now requires at least
a digit before or after the dot.
  • Loading branch information
perlpunk committed Sep 22, 2021
1 parent 35f0417 commit 479b6e4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion lib/yaml/resolver.py
Expand Up @@ -177,7 +177,7 @@ class Resolver(BaseResolver):
Resolver.add_implicit_resolver(
'tag:yaml.org,2002:float',
re.compile(r'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)?
|\.[0-9_]+(?:[eE][-+][0-9]+)?
|\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?
|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*
|[-+]?\.(?:inf|Inf|INF)
|\.(?:nan|NaN|NAN))$''', re.X),
Expand Down
2 changes: 0 additions & 2 deletions tests/data/yaml11.schema-skip
@@ -1,8 +1,6 @@
load: {
'Y': 1, 'y': 1, 'N': 1, 'n': 1,
'!!bool Y': 1, '!!bool N': 1, '!!bool n': 1, '!!bool y': 1,
'._', '!!str ._',
'._14', '!!str ._14'
}
dump: {
'!!str N': 1, '!!str Y': 1, '!!str n': 1, '!!str y': 1,
Expand Down

0 comments on commit 479b6e4

Please sign in to comment.