Created
November 21, 2024 18:13
-
-
Save reyjrar/dba8b1aa49b011fe5f1af0abd077819b to your computer and use it in GitHub Desktop.
YAML Implementations Borked
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using the PurePerl implementation written by the author of the YAML Spec | |
brad@beta $ perl -MYAML -MDDP -E'my $y = "country: NO"; my $x = YAML::Load($y); p($x)' | |
{ | |
country "NO" | |
} | |
brad@beta $ perl -MYAML -MDDP -E'my $y = "date: 0000-00-00"; my $x = YAML::Load($y); p($x)' | |
{ | |
date "0000-00-00" | |
} | |
# Using libyaml C library | |
brad@beta $ perl -MYAML::XS -MDDP -E'my $y = "country: NO"; my $x = YAML::XS::Load($y); p($x)' | |
{ | |
country "NO" | |
} | |
brad@beta $ perl -MYAML::XS -MDDP -E'my $y = "date: 0000-00-00"; my $x = YAML::XS::Load($y); p($x)' | |
{ | |
date "0000-00-00" | |
} | |
# What the actual fuck is this? | |
brad@beta $ python3 -c 'import yaml ; y="country: NO" ; x=yaml.safe_load(y) ; print(yaml.dump(x))' | |
country: false | |
brad@beta $ python3 -c 'import yaml ; y="date: 0000-00-00" ; x=yaml.safe_load(y) ; print(yaml.dump(x))' | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
import yaml ; y="date: 0000-00-00" ; x=yaml.safe_load(y) ; print(yaml.dump(x)) | |
~~~~~~~~~~~~~~^^^ | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/__init__.py", line 125, in safe_load | |
return load(stream, SafeLoader) | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/__init__.py", line 81, in load | |
return loader.get_single_data() | |
~~~~~~~~~~~~~~~~~~~~~~^^ | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/constructor.py", line 51, in get_single_data | |
return self.construct_document(node) | |
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/constructor.py", line 60, in construct_document | |
for dummy in generator: | |
^^^^^^^^^ | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/constructor.py", line 413, in construct_yaml_map | |
value = self.construct_mapping(node) | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/constructor.py", line 218, in construct_mapping | |
return super().construct_mapping(node, deep=deep) | |
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/constructor.py", line 143, in construct_mapping | |
value = self.construct_object(value_node, deep=deep) | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/constructor.py", line 100, in construct_object | |
data = constructor(self, node) | |
File "/Users/brad/tmp/yaml/lib/python3.13/site-packages/yaml/constructor.py", line 330, in construct_yaml_timestamp | |
return datetime.date(year, month, day) | |
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ | |
ValueError: year 0 is out of range |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment