summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Allow question marks in plain scalars in flow collections (#105)Tina Müller (tinita)2020-06-011-1/+1
| | | | | | | | | | | | | | | See http://yaml.org/spec/1.1/#id907281 The question mark isn't mentioned as something special here, only ,[]{} This commit will allow [foo?bar] [foo ? bar] The PR does only change the behaviour when the question mark is in the middle or at the end of the string, not at the beginning, e.g. [?foo] is handled by a different part of the code.
* Emitter: Don't output trailing space for empty scalar nodes (#186)Tina Müller (tinita)2020-06-011-1/+11
| | | | | | | | | | | | | | | | | | | | See issue #46 Passing emitter tests: * 2XXW: Spec Example 2.25. Unordered Sets * 5WE3: Spec Example 8.17. Explicit Block Mapping Entries * 6KGN: Anchor for empty node * 6XDY: Two document start markers * 7W2P: Block Mapping with Missing Values * 8KB6: Multiline plain flow mapping key without value * 9BXH: Multiline doublequoted flow mapping key without value * C2DT: Spec Example 7.18. Flow Mapping Adjacent Values * JTV5: Block Mapping with Multiline Scalars * KK5P: Various combinations of explicit block mappings * LE5A: Spec Example 7.24. Flow Nodes * UT92: Spec Example 9.4. Explicit Documents * W42U: Spec Example 8.15. Block Sequence Entry Types * W4TN: Spec Example 9.5. Directives Documents * ZWK4: Key with anchor after missing explicit mapping value
* Emitter: Output space after an alias mapping key (#185)Tina Müller (tinita)2020-06-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Before: a: &b x *b: c Now: a: &b x *b : c Passing tests: * 26DV: Whitespace around colon in mappings * E76Z: Aliases in Implicit Block Mapping * X38W: Aliases in Flow Objects Test manually because `make test-suite` will overwrite changes in the skiplist: ./tests/run-parser-test-suite tests/run-test-suite/data/26DV/in.yaml | ./tests/run-emitter-test-suite ./tests/run-parser-test-suite tests/run-test-suite/data/E76Z/in.yaml | ./tests/run-emitter-test-suite ./tests/run-parser-test-suite tests/run-test-suite/data/X38W/in.yaml | ./tests/run-emitter-test-suite Or edit tests/run-test-suite/test/blacklist/libyaml-emitter and do: (cd tests/run-test-suite; prove -lv test) Also I added some newlines to yaml.h to help identifying states by number.
* Flow indicators can not be part of local or shorthand tags (#179)Tina Müller (tinita)2020-06-011-14/+22
| | | | Spec: https://yaml.org/spec/1.2/spec.html#ns-tag-char Test: https://github.com/yaml/yaml-test-suite/blob/master/test/WZ62.tml
* Fix logic for document end before directiveTina Müller2020-04-191-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | open_ended can have three states now: 0: The previous document was ended explicitly with '...' 1: The previous document wasn't ended with '...' 2: The last scalar event was a block scalar with trailing empty lines |+, and last document wasn't ended with '...'. Important at stream end. This was broken in the past, and fixed in fa1293a. With my last PR #162 I added the faulty behaviour again. The problematic behaviour showed only when all of the following conditions were true: * writing YAML directives * writing unquoted top level scalars * writing more than one document ================== BROKEN ============================== The first example shows that the document end marker is not emitted before the next document. This would be valid in YAML 1.1 if the scalar was quoted, but not if it is plain. This commit fixes this. echo '--- foo --- bar ' | ./tests/run-parser-test-suite | ./tests/run-emitter-test-suite --directive 1.1 %YAML 1.1 --- foo %YAML 1.1 --- bar ================== FIXED ============================== echo '--- foo --- bar ' | ./tests/run-parser-test-suite | ./tests/run-emitter-test-suite --directive 1.1 %YAML 1.1 --- foo ... %YAML 1.1 --- bar ======================================================= Other examples which should look like this (and were correct already before this fix): Open ended scalars like |+ need '...' at the end of the stream: echo '--- |+ a --- |+ a ' | ./tests/run-parser-test-suite | ./tests/run-emitter-test-suite --- |+ a --- |+ a ... ======================================================= If a document is ended with an explicit '...', the code should not print '...' twice: echo '--- foo ... --- bar ' | ./tests/run-parser-test-suite | ./tests/run-emitter-test-suite --directive 1.1 %YAML 1.1 --- foo ... %YAML 1.1 --- bar ==========================================================
* Allow emitting 1.2 directiveTina Müller2020-04-191-2/+8
| | | | | | | | Before `1.1` was hardcoded in the emitter. * Also add --directive option to run-emitter-test-suite Allows to easily test how output looks like if %YAML directives are output.
* Support %YAML 1.2 directives (#172)Tina Müller (tinita)2020-04-102-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This will simply allow `%YAML 1.2` directives additionally to `%YAML 1.1`. There is no change in behaviour. See also #20 No changes are needed regarding tag directives. In YAML 1.2 tag directives are for the following document only. This is already implemented like that in libyaml. We would rather have to fix the code if we want to have the correct behaviour (global directives) in YAML 1.1. This would be a bit more complicated, as we would have to save the default version and the current version in the parser object. New passing parser tests: * 27NA: Spec Example 5.9. Directive Indicator * 6ZKB: Spec Example 9.6. Stream * 9DXL: Spec Example 9.6. Stream [1.3] * RTP8: Spec Example 9.2. Document Markers New failing error parser tests (before they were errors for the wrong reason): * EB22: Missing document-end marker before directive * RHX7: YAML directive without document end marker
* Avoid recursion in the document loader. (#127)Michael Drake2020-04-101-103/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The document loading API (yaml_parser_load) was susseptable to a stack overflow issue when given input data which opened many mappings and/or sequences without closing them. This was due to the use of recurion in the implementation. With this change, we avoid recursion, and maintain our own loader context stack on the heap. The loader context contains a stack of document node indexes. Each time a sequence or mapping start event is encountered, the node index corrasponding to the event is pushed to the stack. Each time a sequence or mapping end event is encountered, the corrasponding node's index is popped from the stack. The yaml_parser_load_nodes() function sits on the event stream, issuing events to the appropriate handlers by type. When an event handler function constructs a node, it needs to connect the new node to its parent (unless it's the root node). This is where the loader context stack is used to find the parent node. The way that the new node is added to the tree depends on whether the parent node is a mapping (with a yaml_node_pair_t to fill), or a sequence (with a yaml_node_item_t). Fixes: https://github.com/yaml/libyaml/issues/107
* Fix missing token in example (#169)Ashutosh Chauhan2020-04-101-0/+1
|
* Output document end marker after open ended scalars (#162)Tina Müller (tinita)2020-03-281-0/+12
|
* Always output document end before directive (YAML 1.2 compatibility)Tina Müller2020-03-261-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In YAML 1.1, the document end marker `...` is optional even if the next document starts with a directive: https://github.com/yaml/pyyaml/blob/master/tests/data/spec-07-09.canonical ``` %YAML 1.1 --- !!str "foo" %YAML 1.1 --- !!str "bar" %YAML 1.1 --- !!str "baz" ``` It is only required if the scalar is "open ended", for example for plain scalars. In YAML 1.2 the `...` marker is always required before a directive. My suggestion would be to make the output 1.2 compatible. It will still be 1.1 compatible, so that shouldn't be a problem. I believe this will also make it easier to fix #123 which was introduced with the last fixes regarding `open_ended`. I think I can make a fix for this soon after this issue is fixed. Fixing #123 without this would be a bit more complicated. If we do this, we also need to adjust PyYAML to behave the same. Related issues/commits: - https://github.com/yaml/libyaml/issues/60 - https://github.com/yaml/libyaml/pull/122 - 56400d9, 8ee83c0, 56f4b17
* Fix spellingHonkingGoose2019-07-251-1/+1
|
* Use pointer to const for strings that aren't/shouldn't be modifiedcriptych2019-06-061-11/+11
|
* Fixed typo.SHIBATA Hiroshi2019-06-062-2/+2
|
* build: do not install config.hMarty E. Plummer2018-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | 'config.h' is meant to be a convenience header to be #included at build time, but not installed. Installing it can cause a host of problems for various other projects (for instance, attempting to build u-boot from source while another project's 'config.h' exists in the compiler search path will cause build failures similar to: https://github.com/pepe2k/u-boot_mod/issues/148 Further, I've changed '#include <config.h>' to '#include "config.h"', which should constrain the search path to the current build directories, so if another package with a bugged build has this file installed, it will not cause yaml to miscompile/fail. If you have a file `/usr/include/config.h` on your filesystem, query your package manager to find out what package owns it, and file a bug report against it with your distro maintainers. Signed-off-by: Marty E. Plummer <hanetzer@protonmail.com>
* Fix unconditional yaml_free()Tina Müller2018-07-181-1/+2
| | | | Thanks to @tlsa for spotting this
* fix version_directive memory leakReini Urban2018-07-181-0/+1
| | | | detected by coverity
* yaml_stack_extend: guard against integer overflowFlorian Weimer2018-07-181-1/+6
|
* fix C++ g++-6 errorsReini Urban2018-07-181-3/+3
| | | | yaml_emitter_write_indicator const char *indicator
* fix clang -Wlogical-op warningsReini Urban2018-07-182-3/+3
| | | | Commit amended by @perlpunk after suggestion from @tlsa
* fix C++-compat errorReini Urban2018-07-172-2/+2
| | | | | we cannot malloc to an anon struct in C++. typedef yaml_anchors_t
* Allow colons in plain scalars inside flow collections0.2.2-pre1Tina Müller2018-06-301-3/+14
| | | | | | | | | | | | | | This is a followup to #28 See http://yaml.org/spec/1.1/#nb-plain-char(c) and the following productions. This commit will allow `[http://example]`, but still fail for: - `[:foo]` - `[foo:]` See https://gist.github.com/perlpunk/de2c631a7b0e9002de351a680eadb573 for all the relevant cases where this change applies.
* Fix yaml_document_deleteReini Urban2018-06-301-5/+0
| | | | Remove unneeded context, which is not set in any macro.
* Fix typo errorwhiteUnicorn2018-06-301-1/+1
| | | nessesary to necessary
* The closing single quote needs to be indented...Tina Müller2018-06-301-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | if it's on its own line. ``` % cd libyaml % echo "+STR +DOC +SEQ =VAL '\\\n -SEQ -DOC -STR" | ./tests/run-emitter-test-suite - ' ' % # fix % make ... % echo "+STR +DOC +SEQ =VAL '\\\n -SEQ -DOC -STR" | ./tests/run-emitter-test-suite - ' ' ```
* Fix token name typos in commentsViktor Szakats2018-06-301-2/+2
|
* Don't emit document-end marker at the end of streamTina Müller2018-06-301-7/+0
| | | | | | | | (only when explicitly requested) @jrtc27++ for the patch. See #60
* Revert removing of open_ended after top level plain scalarTina Müller2018-06-291-0/+4
| | | | | | | | See also issue #60 Revert "This code is not needed and breaks tests" This reverts commit 56400d976a1999156b1abfd674c3122843980260.
* Remove need for PTRDIFF_MAXRoger Peppe2018-01-112-25/+14
| | | | It's just as easy to calculate the maximum value directly.
* Fixed most compiler warnings -Wall -WextraReini Urban2018-01-087-58/+78
| | | | | | | | | | | repro: CFLAGS="-Wall -Wextra -Wunused-parameter -Wc++-compat" ./configure && make which we use for perl, and libyaml is now included in cperl. Tested with gcc-5 and clang-3.7 There are still a tons of format warnings (%d on 64bit) in example-deconstructor.c which I skipped.
* Compilation fix for SolarisAndy Grundman2018-01-081-1/+6
| | | | From https://github.com/ingydotnet/yaml-libyaml-pm/issues/24
* add -no-undefined to src/Makefile.amMarty E. Plummer2018-01-061-1/+1
| | | | | | | | Without this change building a dll with the mingw-w64 toolchain is impossible. All tests from make test-all succeed on native linux (Gentoo amd64 glibc default/linux/amd64/17.1/desktop gcc-7.2.0) Signed-off-by: Marty E. Plummer <hanetzer@protonmail.com>
* Define PTRDIFF_MAX if it's not in stdint.hTina Müller2017-12-231-0/+7
| | | | Seems to be the case on HP-UX
* Forbid escaped singlequote in doublequotesTina Müller2017-12-021-4/+0
| | | | See also issue #68
* Fix unitialized value crash found by OSS FuzzIan Cordasco2017-05-131-0/+5
| | | | | | | Google's OSS Fuzz project found input for libyaml that was capable of triggering an uninitialized value crash. Patch provided by Alex Gaynor
* Add -Wall to list of compile flagsIan Cordasco2016-12-291-1/+1
| | | | | Let's start warning on everything and we'll clean the warnings up as we go along.
* Fix misspell: preceedLeo Arias2016-12-071-4/+4
| | | https://en.wiktionary.org/wiki/preceed
* Removed trailing-whitespacesSHIBATA Hiroshi2016-11-236-20/+16
|
* Picked typofix from Ruby's Psych parserSHIBATA Hiroshi2016-11-232-21/+21
| | | | | See also https://github.com/ruby/psych/commit/66fb7fb77533d0606748940288858794752d95cb
* spec-1.2 rule [53]Ingy döt Net2016-10-061-0/+4
| | | | Support "\/" for JSON compatability.
* This code is not needed and breaks testsIngy döt Net2016-09-211-4/+0
| | | | | | | | This code was disabled in Perl binding for breaking tests. Kirill said on IRC: < rz> ingy: i'm not sure why i set open_ended in yaml_emitter_write_plain_scalar
* Fixed segfault in yaml_string_write_handler.Kirill Simonov2016-06-051-1/+1
|
* Removed invalid simple key assertion (thank to Jonathan Gray).Kirill Simonov2014-11-281-7/+0
|
* Fixed heap overflow in yaml_parser_scan_uri_escapes (Thanks Ivan Fratric of ↵0.1.6Kirill Simonov2014-03-262-2/+8
| | | | the Google Security Team).
* Manually define PTRDIFF_MAX for VS C compiler.0.1.5Kirill Simonov2014-02-031-0/+9
|
* Forgot to set the error state.Kirill Simonov2014-02-031-2/+6
|
* Limit input size to SIZE_MAX/2.Kirill Simonov2014-02-032-0/+5
|
* Guard against overflows in indent and flow_level.Kirill Simonov2014-02-022-7/+14
|
* Prevent node index overflow (Reported by Florian Weimer).Kirill Simonov2014-02-022-0/+18
|
* Fixed invalid size_t->int cast (Thank to Florian Weimer).Kirill Simonov2014-01-121-1/+1
|