summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtest/test.py1
-rw-r--r--yq/loader.py4
2 files changed, 4 insertions, 1 deletions
diff --git a/test/test.py b/test/test.py
index d54a351..9cb570f 100755
--- a/test/test.py
+++ b/test/test.py
@@ -320,6 +320,7 @@ class TestYq(unittest.TestCase):
def test_yaml_1_1_octals(self):
self.assertEqual(self.run_yq("on: -012345", ["-y", "."]), "'on': -5349\n")
+ self.assertEqual(self.run_yq("on: '0900'", ["-y", "."]), "'on': '0900'\n")
@unittest.expectedFailure
def test_yaml_1_2_octals(self):
diff --git a/yq/loader.py b/yq/loader.py
index 4ff6aa5..e477814 100644
--- a/yq/loader.py
+++ b/yq/loader.py
@@ -19,6 +19,7 @@ except ImportError:
from yaml import SafeLoader as default_loader # type: ignore
+# Note the 1.1 resolver is modified from the default and only safe for use in dumping, not loading.
core_resolvers = {
"1.1": [
{
@@ -45,9 +46,10 @@ core_resolvers = {
},
{
"tag": "tag:yaml.org,2002:int",
+ # Line 2 of regexp modified to match all decimal digits, not just 0-7, to induce quoting of string scalars
"regexp": re.compile(
r"""^(?:[-+]?0b[0-1_]+
- |[-+]?0[0-7_]+
+ |[-+]?0[0-9_]+
|[-+]?(?:0|[1-9][0-9_]*)
|[-+]?0x[0-9a-fA-F_]+
|[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$""",