2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-08 14:21:06 +00:00

Merge pull request #1262 from m-holger/i1261

Fix writing reals with trailing '.' as JSON (fixes #1261)
This commit is contained in:
m-holger 2024-08-06 01:47:04 +01:00 committed by GitHub
commit 77d1a0cf24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2024-08-06 M Holger <m.holger@qpdf.org>
* Bug fix: when writing real numbers as JSON ensure that they don't
have a trailing decimal point. Fixes #1261.
2024-07-14 M Holger <m.holger@qpdf.org>
* Bug fix: handle named destinations where the entry is a

View File

@ -52,4 +52,7 @@ QPDF_Real::writeJSON(int json_version, JSON::Writer& p)
} else {
p << this->val;
}
if (val.back() == '.') {
p << "0";
}
}

View File

@ -111,6 +111,7 @@ test_main()
check(QPDFObjectHandle::newReal(".34").getJSON(i), "0.34");
check(QPDFObjectHandle::newReal("-0.56").getJSON(i), "-0.56");
check(QPDFObjectHandle::newReal("-.78").getJSON(i), "-0.78");
check(QPDFObjectHandle::newReal("-78.").getJSON(i), "-78.0");
}
JSON jmap2 = JSON::parse(R"({"a": 1, "b": "two", "c": [true]})");
std::map<std::string, std::string> dvalue;