mirror of
https://github.com/qpdf/qpdf.git
synced 2024-05-29 00:10:54 +00:00
Warn for duplicated dictionary keys (fixes #345)
This commit is contained in:
parent
5ce287d6bb
commit
8b1e307741
|
@ -1,3 +1,10 @@
|
||||||
|
2019-09-19 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* Warn when duplicated dictionary keys are found during parsing.
|
||||||
|
The behavior remains as before: later keys override earlier ones.
|
||||||
|
However, this generates a warning now rather than being silently
|
||||||
|
ignored. Fixes #345.
|
||||||
|
|
||||||
2019-09-17 Jay Berkenbilt <ejb@ql.org>
|
2019-09-17 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* QIntC tests: don't assume char is signed. Fixes #361.
|
* QIntC tests: don't assume char is signed. Fixes #361.
|
||||||
|
|
|
@ -2135,7 +2135,18 @@ QPDFObjectHandle::parseInternal(PointerHolder<InputSource> input,
|
||||||
{
|
{
|
||||||
val = olist.at(++i);
|
val = olist.at(++i);
|
||||||
}
|
}
|
||||||
dict[key_obj.getName()] = val;
|
std::string key = key_obj.getName();
|
||||||
|
if (dict.count(key) > 0)
|
||||||
|
{
|
||||||
|
QTC::TC("qpdf", "QPDFObjectHandle duplicate dict key");
|
||||||
|
warn(context,
|
||||||
|
QPDFExc(
|
||||||
|
qpdf_e_damaged_pdf,
|
||||||
|
input->getName(), object_description, offset,
|
||||||
|
"dictionary has duplicated key " + key +
|
||||||
|
"; last occurrence overrides earlier ones"));
|
||||||
|
}
|
||||||
|
dict[key] = val;
|
||||||
}
|
}
|
||||||
object = newDictionary(dict);
|
object = newDictionary(dict);
|
||||||
setObjectDescriptionFromInput(
|
setObjectDescriptionFromInput(
|
||||||
|
|
|
@ -445,3 +445,4 @@ QPDF eof skipping spaces before xref 1
|
||||||
QPDF_encryption user matches owner V < 5 0
|
QPDF_encryption user matches owner V < 5 0
|
||||||
QPDF_encryption same password 1
|
QPDF_encryption same password 1
|
||||||
QPDFWriter stream in ostream 0
|
QPDFWriter stream in ostream 0
|
||||||
|
QPDFObjectHandle duplicate dict key 0
|
||||||
|
|
|
@ -2314,7 +2314,7 @@ my @badfiles = ("not a PDF file", # 1
|
||||||
"bad }", # 14
|
"bad }", # 14
|
||||||
"bad ]", # 15
|
"bad ]", # 15
|
||||||
"bad >>", # 16
|
"bad >>", # 16
|
||||||
"odd number of dictionary items", # 17
|
"dictionary errors", # 17
|
||||||
"bad )", # 18
|
"bad )", # 18
|
||||||
"bad >", # 19
|
"bad >", # 19
|
||||||
"invalid hexstring character", # 20
|
"invalid hexstring character", # 20
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
WARNING: bad17.pdf (trailer, offset 715): dictionary has duplicated key /K; last occurrence overrides earlier ones
|
||||||
WARNING: bad17.pdf (trailer, offset 715): dictionary ended prematurely; using null as value for last key
|
WARNING: bad17.pdf (trailer, offset 715): dictionary ended prematurely; using null as value for last key
|
||||||
/QTest is implicit
|
/QTest is implicit
|
||||||
/QTest is direct and has type null (2)
|
/QTest is direct and has type null (2)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
WARNING: bad17.pdf (trailer, offset 715): dictionary has duplicated key /K; last occurrence overrides earlier ones
|
||||||
WARNING: bad17.pdf (trailer, offset 715): dictionary ended prematurely; using null as value for last key
|
WARNING: bad17.pdf (trailer, offset 715): dictionary ended prematurely; using null as value for last key
|
||||||
/QTest is implicit
|
/QTest is implicit
|
||||||
/QTest is direct and has type null (2)
|
/QTest is direct and has type null (2)
|
||||||
|
|
|
@ -73,6 +73,8 @@ xref
|
||||||
trailer <<
|
trailer <<
|
||||||
/Size 7
|
/Size 7
|
||||||
/Root 1 0 R
|
/Root 1 0 R
|
||||||
|
/K 1
|
||||||
|
/K 2
|
||||||
/Something
|
/Something
|
||||||
>>
|
>>
|
||||||
startxref
|
startxref
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
WARNING: issue-51.pdf: can't find PDF header
|
WARNING: issue-51.pdf: can't find PDF header
|
||||||
WARNING: issue-51.pdf: reported number of objects (0) is not one plus the highest object number (8)
|
WARNING: issue-51.pdf: reported number of objects (0) is not one plus the highest object number (8)
|
||||||
|
WARNING: issue-51.pdf (object 7 0, offset 476): dictionary has duplicated key /0000; last occurrence overrides earlier ones
|
||||||
WARNING: issue-51.pdf (object 7 0, offset 553): expected endobj
|
WARNING: issue-51.pdf (object 7 0, offset 553): expected endobj
|
||||||
|
WARNING: issue-51.pdf (object 1 0, offset 236): dictionary has duplicated key /00000000; last occurrence overrides earlier ones
|
||||||
WARNING: issue-51.pdf (object 1 0, offset 359): expected endobj
|
WARNING: issue-51.pdf (object 1 0, offset 359): expected endobj
|
||||||
WARNING: issue-51.pdf (offset 70): loop detected resolving object 2 0
|
WARNING: issue-51.pdf (offset 70): loop detected resolving object 2 0
|
||||||
WARNING: issue-51.pdf (object 2 0, offset 26): /Length key in stream dictionary is not an integer
|
WARNING: issue-51.pdf (object 2 0, offset 26): /Length key in stream dictionary is not an integer
|
||||||
|
|
Loading…
Reference in New Issue
Block a user