mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Ensure that we handle indirect objects in all types of Opt
entries in ChoiceWidget
annotation dictionaries
I haven't got an example where the current code breaks, but given all the previous cases we've seen where PDF generators use indirect objects in Arrays it makes sense to fix this pro-actively. I've modified the relevant unit-tests slightly, and they would *not* pass without the code changes in this patch. *Note:* `Dict_getArray` only dereferences Array elements on the "top-level", to avoid recursion issues. Furthermore if you have to loop through the Array at the call-site anyway, then using `Dict_get` in combination with `XRef_fetchIfRef` is a tiny bit more efficient.
This commit is contained in:
parent
a719b71e59
commit
bd91f34513
2 changed files with 21 additions and 8 deletions
|
@ -779,14 +779,16 @@ var ChoiceWidgetAnnotation = (function ChoiceWidgetAnnotationClosure() {
|
|||
// it to an array of arrays as well for convenience in the display layer.
|
||||
this.data.options = [];
|
||||
|
||||
var options = params.dict.getArray('Opt');
|
||||
var options = params.dict.get('Opt');
|
||||
if (isArray(options)) {
|
||||
var xref = params.xref;
|
||||
for (var i = 0, ii = options.length; i < ii; i++) {
|
||||
var option = options[i];
|
||||
var option = xref.fetchIfRef(options[i]);
|
||||
var isOptionArray = isArray(option);
|
||||
|
||||
this.data.options[i] = {
|
||||
exportValue: isArray(option) ? option[0] : option,
|
||||
displayValue: isArray(option) ? option[1] : option,
|
||||
exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
|
||||
displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue