Commit graph

58 commits

Author SHA1 Message Date
Tina Müller
8f27932796 Fix float resolver for '.' and '._'
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.
2021-09-23 14:42:00 -07:00
Tina Müller
b3d2d674b7 Add a test for the YAML 1.1 types 2021-09-23 14:42:00 -07:00
Thom Smith
961ce9dcf5 Fix issue with representing Enum types 2021-09-23 14:42:00 -07:00
Ingy döt Net
8a01c99c63 Move test files back into tests/data/ 2020-03-18 21:58:22 +01:00
Riccardo Schirone
5080ba5133
Prevents arbitrary code execution during python/object/new constructor (#386)
* Prevents arbitrary code execution during python/object/new constructor

In FullLoader python/object/new constructor, implemented by
construct_python_object_apply, has support for setting the state of a
deserialized instance through the set_python_instance_state method.
After setting the state, some operations are performed on the instance
to complete its initialization, however it is possible for an attacker
to set the instance' state in such a way that arbitrary code is executed
by the FullLoader.

This patch tries to block such attacks in FullLoader by preventing
set_python_instance_state from setting arbitrary properties. It
implements a blacklist that includes `extend` method (called by
construct_python_object_apply) and all special methods (e.g. __set__,
__setitem__, etc.).

Users who need special attributes being set in the state of a
deserialized object can still do it through the UnsafeLoader, which
however should not be used on untrusted input. Additionally, they can
subclass FullLoader and redefine `get_state_keys_blacklist()` to
extend/replace the list of blacklisted keys, passing the subclassed
loader to yaml.load.

* Make sure python/object/new constructor does not set some properties

* Add test to show how to subclass FullLoader with new blacklist
2020-03-17 19:09:55 +01:00
Tina Müller (tinita)
4fcdcdbf60 Add tests for timezone (#363)
After #163, this adds some test data to check if the datetime objects
return the correct timezone
2019-12-20 20:38:46 +01:00
Tina Müller
a826f546c2 Enable certain unicode tests when maxunicode not > 0xffff
They were disabled in d6cbff6620

After #351 the tests are working again
2019-12-20 20:38:46 +01:00
Tina Müller (tinita)
03b378d039
Allow add_multi_constructor with None (#358)
Loader.add_multi_constructor(None, myconstructor)

Also add test for add_multi_constructor('!', ...) etc.

See issue #317
2019-12-07 22:40:48 +01:00
Filip Salomonsson
5a0cfab86f Fix handling of __slots__ (#161) 2019-12-07 22:34:23 +01:00
Tina Müller
d6cbff6620 Skip certain unicode tests when maxunicode not > 0xffff 2019-03-12 16:22:31 -07:00
Tina Müller
07c88c6c1b Allow to turn off sorting keys in Dumper 2019-03-08 09:09:48 -08:00
Peter Murphy
c60232d69a Added emoticon test data files (which will probably break testing) 2017-05-09 23:07:36 +10:00
Daniel Beer
c5b135fe39 Allow colon in a plain scalar in a flow context (#45)
* Allow colon in a plain scalar in a flow context

* Restore behavior of flow mapping with empty value
2017-02-08 13:50:53 -06:00
Kirill Simonov
7eeba34467 removed a test which fails when wheel is imported. 2016-06-16 23:01:38 -05:00
Kirill Simonov
335c34455d Fixed a problem with a scanner error not detected when no line break at the end of the stream. 2009-08-29 22:12:45 +00:00
Kirill Simonov
fa14e18b38 Fixed emitting of invalid BOM for UTF-16. 2009-08-29 20:59:56 +00:00
Kirill Simonov
706e36ab64 Fixed a problem when CDumper incorrectly serializes a node anchor. 2009-08-29 19:15:31 +00:00
Kirill Simonov
bf272b0339 Fixed str/bytes issues with Python 3 in _yaml.pyx. 2008-12-30 13:30:52 +00:00
Kirill Simonov
5f5e9a9494 Handle the encoding of input and output streams in a uniform way. 2008-12-30 04:02:04 +00:00
Kirill Simonov
ab8d940469 Share data files between Py2 and Py3 test suites. 2008-12-29 19:05:11 +00:00
Kirill Simonov
1e842301f4 Fixed an issue with ReaderError generated by the LibYAML wrapper. 2008-12-28 20:41:41 +00:00
Kirill Simonov
aff84ff195 Refactored the test suite; updated include and library paths in setup.cfg. 2008-12-28 20:16:50 +00:00
Kirill Simonov
93f64d3c79 Fixed test errors for LibYAML bindings; added a test on emitting nodes in all possible styles. 2008-12-27 19:09:03 +00:00
Kirill Simonov
3ded20780b Added a test for single dot being a float bug. 2008-09-30 11:56:14 +00:00
Kirill Simonov
046f114050 Make compose() and load() ensure that the input stream contains a single document. Fixes #54. 2007-08-21 20:25:34 +00:00
Kirill Simonov
e5059a1d53 Add the tests for checking the libyaml bug. 2007-03-22 16:12:36 +00:00
Kirill Simonov
ed79023a71 Fix loss of microsecond precision in datetime.datetime constructor (fix #30).
Thanks to edemaine@mit.edu for the bug report and the patch.
2006-10-04 07:42:50 +00:00
Kirill Simonov
cc9c738342 Fix loading an empty YAML stream. 2006-09-12 13:53:30 +00:00
Kirill Simonov
b4643e77c3 Fix a test to work under Python 2.3. 2006-08-20 09:10:47 +00:00
Kirill Simonov
8f9b8bed40 The 'N' plain scalar was still recognized as `!!bool`. Fix it (close #26). 2006-08-16 21:07:47 +00:00
Kirill Simonov
29413ea88e Fix timestamp constructing and representing (close #25). 2006-08-16 18:22:38 +00:00
Kirill Simonov
17fa129ada Completely rewrite the libyaml bindings. 2006-08-13 13:46:20 +00:00
Kirill Simonov
8b083c6a96 Subclass all base classes from object.
Hold references to the objects being represented (should fix #22).

The value of a mapping node is represented as a list of pairs `(key, value)`
now.

Sort dictionary items (fix #23).

Recursive structures are now loaded and dumped correctly, including complex
structures like recursive tuples (fix #5). Thanks Peter Murphy for the patches.
To make it possible, representer functions are allowed to be generators.
In this case, the first generated value is an object. Other values produced
by the representer are ignored.

Make Representer not try to guess `!!pairs` when a list is represented.
You need to construct a `!!pairs` node explicitly now.

Do not check for duplicate mapping keys as it didn't work correctly anyway.
2006-08-03 16:07:29 +00:00
Kirill Simonov
2e6c774c92 Fix a bug when a block scalar is incorrectly emitted in the simple key context. 2006-07-30 12:51:05 +00:00
Kirill Simonov
63fa1bd6fe To make porting easier, rewrite Parser not using generators.
Fix handling of unexpected block mapping values, like
{{{
: foo
}}}

Remove obsolete and unused {{{__iter__}}} functions.
2006-07-03 11:29:45 +00:00
Kirill Simonov
27de2ba1fc Fix invalid output of single-quoted scalars in cases when a single
quote is not escaped when preceeded by whitespaces or line breaks.
(Fix #17).
2006-06-30 08:10:36 +00:00
Kirill Simonov
bcfc0b6dda Fix several problems caused by ill-formed documents.
The line number is not calculated correctly for DOS-style line breaks.

Fix error reporting in '''remove_possible_simple_key'''. The problem is caused by the document:

{{{
+foo: &A bar
+*A ]
}}}

Raise an error for a complex key which is not indented correctly, for instance:

{{{
? "foo"
 : "bar"
}}}
2006-06-16 07:23:05 +00:00
Kirill Simonov
d01a85fe5c Add ind and qnan values to a float test. 2006-05-24 15:45:38 +00:00
Kirill Simonov
a109c6bfce Add a test case belonging to the previous commit. 2006-05-22 19:50:32 +00:00
Kirill Simonov
ee2fb1c41d Add a test case for #15. 2006-05-21 07:27:26 +00:00
Kirill Simonov
dd2da8afa4 Fix a bug in a test. 2006-05-06 22:12:53 +00:00
Kirill Simonov
74f8caa6fb Fix #11 (Thanks to edemaine(at)mit.edu). 2006-05-06 22:09:50 +00:00
Kirill Simonov
410d822bd5 Prepare setup.py for release. Fix #7. 2006-04-23 18:07:52 +00:00
Kirill Simonov
fc01755908 Raise an error for colons in the flow context. 2006-04-23 13:40:57 +00:00
Kirill Simonov
c87ce16706 Add support for pickling/unpickling python objects. 2006-04-22 20:40:43 +00:00
Kirill Simonov
cce15169da Fix !!python/name for Python 2.3. Clear the yaml module namespace. 2006-04-21 17:31:29 +00:00
Kirill Simonov
89cc4e3e4f Add more unit tests. 2006-04-18 19:33:30 +00:00
Kirill Simonov
95b3cef7eb Add more unit tests for error messages. 2006-04-18 16:48:00 +00:00
Kirill Simonov
24f8ae0e00 Rename error-message to loader-error and add new examples. 2006-04-18 14:35:46 +00:00
Kirill Simonov
ea23091a5b Fix #4 (Thanks to murphy(at)rubychan.de) 2006-04-17 06:42:08 +00:00