* Fix a parser bug where tokens are misidentified as commas.
In the old and new readers, when parsing an object, a comment
followed by any non-`}` token is treated as a comma.
The new unit test required changing the runjsontests.py
flag regime so that failure tests could be run with default settings.
* Honor allowComments==false mode.
Much of the comment handling in the parsers is bespoke, and does not
honor this flag. By unfiying it under a common API, the parser is
simplified and strict mode is now more correctly strict.
Note that allowComments mode does not allow for comments in
arbitrary locations; they are allowed only in certain positions.
Rectifying this is a bigger effort, since collectComments mode requires
storing the comments somewhere, and it's not immediately clear
where in the DOM all such comments should live.
---------
Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
Return 1.9.1 functionality where values too large to fit in
double are converted to positive or negative infinity.
Commit 645cd04 changed functionality so that large floats cause
parse error, while version 1.9.1 accepted them as infinite.
This is problematic because writer outputs infinity values
as `1e+9999`, which could no longer be parsed back.
Fixed also legacy Reader even though it did not parse large values
even before breaking change, due to problematic output/parse asymmetry.
`>>` operator sets value to numeric_limits::max/lowest value if
representation is too large to fit to double. [1][2] In macos
value appears to be parsed to infinity.
> | value in *val* | description |
> |--------------------------|-------------|
> | numeric_limits::max() | The sequence represents a value too large for the type of val |
> | numeric_limits::lowest() | The sequence represents a value too large negative for the type of val |
[1] https://www.cplusplus.com/reference/istream/istream/operator%3E%3E/
[2] https://www.cplusplus.com/reference/locale/num_get/get/
Signed-off-by: Tero Kinnunen <tero.kinnunen@vaisala.com>
Co-authored-by: Tero Kinnunen <tero.kinnunen@vaisala.com>
This patch fixes a fuzzing bug by resolving a bad fallthrough in the
setComment logic.
The result is that we get a proper error instead of an assert, making
the library friendlier to use and less likely to cause issue for
consumers.
See related Chromium project bug:
https://bugs.chromium.org/p/chromium/issues/detail?id=989851
Issue: 1182
A recent PR broken the JsonChecker tests by adding support for trailing
commas. This didn't end up breaking the build, because those tests
aren't run, except locally and only using CMake.
This patch fixes the tests by adding exclusions for trailing comma
tests, as well as updates Meson to run these tests as part of `ninja
test`.
See issue #1102.
1) Improve travis build script for use outside travis.
Allow the script used for CI builds to also be used
locally in a similar manner to the CI use of the scrips
2) Add ctest compatible testing and CDASH support
Report testing and building results to
https://my.cdash.org/index.php?project=jsoncpp
NOTE: The new ctest infrastructure is not yet robust on winodws
Do no yet enable the new features for running test with ctest
on windows platform. The previous behaviors are maintainted,
but enhance test reporting from windows is not yet supported.
3) Add a cmake coverage testing option
Ensure that cmake builds on linux are tested.
Ensure that code coverage is reported.
4) Move conditional environment checking into the matrix
Avoid multiple places where conditional logic is used to
change compiler behavior. As more test environments are
created fromt the travis.yml matrix, all settings should be
obvious from that one location.
5) Tests with known regressions from the jsonchecker are suppressed
Tests that are known to pass with jsoncpp more lenient
syntax enforcement are exluded from tests in test/runjsontests.py
Google advises its employees to add Google Inc. as an author, but that hasn't
been done yet and would be super inconvenient. So instead I've refactored the
file to refer to "The JsonCpp Authors", which are listed in the AUTHORS file.
The AUTHORS file itself is generated via:
git log --pretty="%an <%ae>%n%cn <%ce>" | sort | uniq
Plus the addition of "Google Inc." as a copyright author. (Google owns the work
of anyone contributing from an @google.com address, for example.)
The list contains some probable duplicates where people have used more than one
email address. I didn't deduplicate because -- well, who's to say they're
duplicates, anyway? :)
This change adds explicit copyright information too python
files files. The copyright year used in each case is the
date of the first git commit of each file.
The goal is to allow jsoncpp to be integrated into the
chromium source tree which requires license information in
each source file.
fixes#234
Newlines from comments separated by lines are retained when comments
are appended, so adding a newline between separate comments for a
node is not needed.
This patch fixes some aspects of reading and writing comments:
- Multiple C++-style comments before a Json value had extra newlines appended to them. This patch removes the addition of those newlines.
- Comments written before Json values in the StyledWriter were not indented to match the indentation level of the value. This patch adds indentation to comments.
- Fixed inconsistency in newlines following C- and C++-style comments being saved as part of the comment. All newlines at the end of a comment are now removed.
- Added an additional test of comments.
https://sourceforge.net/p/jsoncpp/patches/25/
- Added Json::ArrayIndex as an unsigned int to forwards.h
- Modified Json::Value to consistently use Json::ArrayIndex.
- Added int/unsigned int constructor overload to Json::Value to avoid ambiguous constructor call.
- Modified jsontestrunner/main.cpp to use Json::valueToString for Value::asInt() conversion to string.
- Modified Json::Reader to only overflow to double when the number is too large (previous code relied on the fact that an int fitted in a double without precision loss).
- Generalized uintToString() helpers and buffer size to automatically adapt to the precision of Json::UInt.
- Added specific conversion logic for UInt to double conversion on Microsoft Visual Studio 6 which only support __int64 to double conversion (unsigned __int64 conversion is not supported)
- Added test for 64 bits parsing/writing. Notes: those will fail when compiled with JSON_NO_INT64 (more dev required to adapt).