1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Follow-up of pr #12344

This commit is contained in:
Calixte Denizet 2020-09-09 11:46:02 +02:00
parent e51e9d1f33
commit 64a6efd95e
9 changed files with 69 additions and 56 deletions

View file

@ -165,6 +165,26 @@ function isWhiteSpace(ch) {
return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
}
/**
* AcroForm field names use an array like notation to refer to
* repeated XFA elements e.g. foo.bar[nnn].
* see: XFA Spec Chapter 3 - Repeated Elements
*
* @param {string} path - XFA path name.
* @returns {Array} - Array of Objects with the name and pos of
* each part of the path.
*/
function parseXFAPath(path) {
const positionPattern = /(.+)\[([0-9]+)\]$/;
return path.split(".").map(component => {
const m = component.match(positionPattern);
if (m) {
return { name: m[1], pos: parseInt(m[2], 10) };
}
return { name: component, pos: 0 };
});
}
export {
getLookupTableFactory,
MissingDataException,
@ -173,6 +193,7 @@ export {
getInheritableProperty,
toRomanNumerals,
log2,
parseXFAPath,
readInt8,
readUint16,
readUint32,