1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

[src/core/writer.js] Support null values in the writeValue function

*This fixes something that I noticed, having recently looked at both the `Lexer.getObj` and `writeValue` code.*

Please note that I unfortunately don't have an example of a form where saving fails without this patch. However, given its overall simplicity and that unit-tests are added, it's hopefully deemed useful to fix this potential issue pro-actively rather than waiting for a bug report.

At this point one might, and rightly so, wonder if there's actually any real-world PDF documents where a `null` value is being used?
Unfortunately the answer is *yes*, and we have a couple of examples in the test-suite (although none of those are related to forms); please see: `issue1015`, `issue2642`, `issue10402`, `issue12823`, `issue13823`, and `pr12564`.
This commit is contained in:
Jonas Jenwald 2021-09-12 18:13:36 +02:00
parent 8f72fc561e
commit 7025b9f859
2 changed files with 7 additions and 1 deletions

View file

@ -89,6 +89,8 @@ function writeValue(value, buffer, transform) {
writeDict(value, buffer, transform);
} else if (isStream(value)) {
writeStream(value, buffer, transform);
} else if (value === null) {
buffer.push("null");
} else {
warn(`Unhandled value in writer: ${typeof value}, please file a bug.`);
}