46 Commits

Author SHA1 Message Date
Ingy döt Net ab16c938fe Add block nesting limit in scanner
Address PR review: also enforce MAX_NESTING_LEVEL
in yaml_parser_roll_indent() for block nesting,
not just flow nesting. Add block nesting test.
2026-05-05 16:34:13 -04:00
Ingy döt Net 8362c8dd96 Enforce nesting limit in scanner
MAX_NESTING_LEVEL was only checked in parser.c, so
yaml_parser_scan() callers had no depth protection.
Deep flow nesting caused O(n²) CPU via simple_keys
scanning. Add the limit check in the scanner's
yaml_parser_increase_flow_level() and a test.
2026-05-05 16:34:13 -04:00
Ryuta Kamizono 1e66c1e13a Fix some typos 2024-04-08 18:33:30 +02:00
Tina Müller 51843fe482 Limit depth of nesting by default
Each nesting level increases the stack and the number of previous
starting events that the parser has to check.

The default maximum is 1000 and can be set via yaml_set_max_nest_level()

I also added new options to run-parser and run-parser-test-suite:
* --max-level: you can now try out this feature on the command line
* --show-error: By default, run-parser doesn't show errors. The new option
  helps with debugging
2024-04-08 18:12:59 +02:00
Tina Müller (tinita) cf53b3b5f9 Add -h and --flow (on|off|keep) to run-*-test-suite (#187)
With `--flow (keep|on)` run-parser-test-suite will output:

    +MAP {}
    +SEQ []

run-emitter-test-suite will then emit flow style collections if requested:

    echo 'foo: [bar, {x: y}]' | ./tests/run-parser-test-suite | ./tests/run-emitter-test-suite
    echo 'foo: [bar, {x: y}]' | ./tests/run-parser-test-suite \
        --flow keep | ./tests/run-emitter-test-suite --flow keep

Also: add that yaml_private.h include again that I had thrown out. Needed
for printing directives.
Wonder if there is a way to create a directive without using the private api.
2020-06-01 00:47:25 +02:00
Tina Müller 0032321756 Remove unnecessary include and malloc 2020-05-21 18:10:59 +02:00
Tina Müller fec20d3fe6 Output error position in run-parser-test-suite.c 2020-05-21 14:50:20 +02:00
Tina Müller 4e5cea6419 Allow emitting 1.2 directive
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.
2020-04-19 12:47:41 +02:00
Michael Drake aa2e89362f Squash a couple of warnings in example-deconstructor-alt
example-deconstructor-alt.c: In function ‘main’:
example-deconstructor-alt.c:649:51: warning:
  comparison between ‘yaml_sequence_style_t {aka enum yaml_sequence_style_e}’
  and ‘enum yaml_mapping_style_e’ [-Wenum-compare]

example-deconstructor-alt.c:650:36: warning:
  comparison between ‘yaml_sequence_style_t {aka enum yaml_sequence_style_e}’
  and ‘enum yaml_mapping_style_e’ [-Wenum-compare]
2019-06-06 20:20:58 +02:00
Tina Müller 78e6ebfb20 Remove stdbool
Might not be available everywhere
2019-02-28 19:50:04 +01:00
Tina Müller 1560fc82ad Make declarations before other statements 2019-02-28 19:40:53 +01:00
Tina Müller 1049e04067 Fix comparison in tests/run-emitter.c 2018-06-30 14:47:34 -07:00
Reini Urban fc2dd942fc Fixed most compiler warnings -Wall -Wextra
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.
2018-01-08 10:44:25 -08:00
Ingy döt Net aa10f65706 Fix problems in CI failures (travis and semaphore)
In the Makefile.am, switched out the fetch (which can have auth problems
in certain envs) with a simple branch per @perlpunk++'s suggestion.

With the new test branches, travis had a problem in that it only clones
one branch and we need the other branch refs to be available. Fixed this
by fetching the other branch refs. I also cleaned up the travis YAML
file.

The Ubuntu 14.04 docker image (used by semaphoreci) had an older git,
without the worktree command, so I made it install the latest git from a
ppa.

Renamed tests/run-tests.sh to tests/run-all-tests.sh for tab completion
conflict reasons.
2018-01-06 14:39:12 -08:00
Ingy döt Net e4aee06ff4 Move tests/run-test-suite to branch run-test-suite
with the intent that `make test-suite` will use it as a branch.

This commit makes the libyaml and yaml-test-suite repos completely
independent. The only thing in master is a Makefile rule for
`make run-test-suite`.

The run-test-suite branch takes care of everything else.

This will keep the master branch history clean from any yaml-test-suite
activity, while keeping everything up to date.

Pinning will just work for whatever commit of master you run the tests
from. The pinning work will all be done in the `run-test-suite` branch.
2017-12-29 19:58:07 -08:00
Tina Müller 61dd999bfe Update libyaml-{parser,emitter}.list
yaml-test-suite/data commit:
daf799e 2017-12-23 "Regenerated data from master 1eacbab"
2017-12-23 17:21:39 +01:00
Tina Müller e5aadc7349 Rewrite make test-suite
No recursive make anymore

Remove MY_LD_LIBRARY_PATH and friends

This is now done by the wrapper script

Remove LIBYAML_DIR variable

not needed anymore

Merge ReadMe.md files to one
2017-12-02 22:23:23 +01:00
Tina Müller fd5bf68a30 Skip 5 tests in libyaml-emitter.list 2017-12-01 14:33:19 +01:00
Jean-Christophe Fillion-Robin fe3d086fa7 Improve CMake build system
New build options
-----------------

* Add option BUILD_TESTING by default ON
See https://cmake.org/cmake/help/v2.8.12/cmake.html#module:CTest

* Simplify library type selection using standard option BUILD_SHARED_LIBS
See https://cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html

yamlConfig.cmake
----------------

* Generate and install yamlConfig.cmake, yamlConfigVersion.cmake and yamlTargets.cmake

* Bump CMake version and explicitly associate include dirs with targets
See https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#include-directories-and-usage-requirements

* Ensure building against libyaml using "find_package(yaml)" uses expected compile options: Set HAVE_CONFIG_H
as private compile option, YAML_DECLARE_STATIC as public

Testing
-------

* Build all examples from "tests" directory

CMake Best practices
--------------------

* configure "config.h" based on version info found in CMakeLists.txt

* Ensure buildsystem re-generation listing sources (best-practice)

It is not recommended to use GLOB to collect a list of source files from
the source tree. If no CMakeLists.txt file changes when a source is added
or removed then the generated build system cannot know when to ask CMake
to regenerate.

See https://cmake.org/cmake/help/v3.8/command/file.html

Compilation warnings
--------------------

* Set _CRT_SECURE_NO_WARNINGS if building using VisualStudio

This will avoid warnings like this one:

```
C:\projects\libyaml\tests\run-emitter.c(268): warning C4996: 'fopen':
This function or variable may be unsafe. Consider using fopen_s instead.
To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for
details.
```

Continuous Integration
----------------------

* travis: Install CMake >= 3.x using scikit-ci-addons

* Add comments to appveyor.yml and run-tests.sh
2017-11-30 07:14:27 -06:00
Ingy döt Net 660242d6a4 Remove deleted test from parser test list. 2017-05-14 13:57:12 +02:00
Ingy döt Net c9878e19bd Switch test-suite run list from black to whitelist
This way as the test suite grows, new tests won't disturb/break our
testing.
2017-02-09 08:24:33 -08:00
Ingy döt Net 7b67c28a39 Skip edge case test M7A3 2017-01-18 18:02:04 +01:00
Ingy döt Net 048095f030 Get tests passing on Docker
The Dockerfiles needed to set LD_LIBRARY_PATH.

For some bizarre reason I needed to build the parser and emitter twice.
Since I plan to redo the building of these binaries later, this is OK
for now, since all tests on all CICDs will pass.

The docker stuff was needed by the semaphoreci system.
2016-12-30 15:54:54 -06:00
Ingy döt Net a672b07109 Include libyaml-test and libyaml-parser-emitter
Before the `make test-suite` command would clone yaml/libyaml-test which
would in tuen clone yaml/libyaml-parser-emitter. Now they are part of
the repository since they are not really useful outside the repository.

They still clone the data branch of yaml/yaml-test-suite. That is where
all the actual test data resides. That belongs outside the repo because
it is intended for all yaml frameworks.
2016-12-30 11:09:58 -06:00
Ingy döt Net 52b6634fb3 Move Travis CI steps into a Bash script
This allows us to run the same Travis testing locally.

Examples:

    ./tests/run-tests.sh
2016-12-29 19:09:53 -06:00
Ian Cordasco 70342132b4 Fix pointer and enum warnings in deconstructor-alt
This should cover the remainder of the warnings found on the Travis CI
OSX builder.
2016-12-29 15:55:41 -06:00
Ian Cordasco 49be466cb1 Fix pointer warnings in example-deconstructor
There were several places in our test deconstructor where we were
passing plain char[]s to functions expecting (yaml_char_t *)s. Since we
will soon be forcing warnings to become errors, it makes sense to clean
these up.
2016-12-29 15:55:41 -06:00
Ian Cordasco b6cc3a689d Add -Wall to list of compile flags
Let's start warning on everything and we'll clean the warnings up as we
go along.
2016-12-29 15:55:41 -06:00
Ian Cordasco 44d49c9019 Fix -Wformat compilation errors in tests
There were several warnings generated by formatting errors in the tests,
this corrects the format strings and silences the warnings.
2016-12-17 13:27:18 -08:00
Kirill Simonov 45cf8b5411 Fixed error handling in run-emitter example. 2016-07-04 21:58:23 -05:00
Kirill Simonov 3b570fc9ab Examples: prevent crashes on some input files (thank to Mathias Svensson). 2016-06-26 22:28:25 -05:00
Kirill Simonov dfe448315f Fixed double free in an example. 2016-06-20 19:22:50 -05:00
Kirill Simonov 0122490194 Undefine the NDEBUG directive for the test programs. 2007-01-08 16:13:59 +00:00
Kirill Simonov e27a3c886e Add functions for constructing, parsing and emitting YAML documents. 2007-01-07 20:11:16 +00:00
Kirill Simonov 609cce0ef9 Older versions of gcc do not know about -Wno-pointer-sign. 2006-08-15 17:21:01 +00:00
Kirill Simonov 028f3e8709 Prepare the initial release. 2006-08-01 11:28:16 +00:00
Kirill Simonov 2a02dfd262 Add two examples and prepare the build system for distribution. 2006-07-31 22:24:32 +00:00
Kirill Simonov b3043c486c Add the run-emitter test. 2006-07-30 12:50:15 +00:00
Kirill Simonov 6d1672817d Fix Emitter bugs and leaks. 2006-07-30 12:49:17 +00:00
Kirill Simonov 54815ffd34 Fix some leaks, segfaults and warnings. 2006-07-21 18:29:00 +00:00
Kirill Simonov 625fcfe9ed Refactor internal and external API. 2006-07-21 13:50:32 +00:00
Kirill Simonov 5eff53a4ac Move yaml/yaml.h to yaml.h and merge version.c to api.c. 2006-07-03 13:49:14 +00:00
Kirill Simonov 2fa16060e0 Complete buffering and encoding code. 2006-06-01 20:19:43 +00:00
Kirill Simonov 3d790dfd5e Complete UTF-8 and UTF-16 decoders.
Reader is mostly done (though untested).
2006-05-30 17:49:18 +00:00
Kirill Simonov 721c1923e4 Add doxygen support. 2006-05-21 14:58:32 +00:00
Kirill Simonov cec6fc98eb Add the basic autoconf infrastructure. 2006-05-20 22:43:15 +00:00