Merge pull request #14738 from Snuffleupagus/xfa-datasets-decode
Decode non-ASCII values found in the xfa:datasets (PR 14735 follow-up)
This commit is contained in:
commit
38e9a46a85
@ -13,9 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { stringToUTF8String, warn } from "../shared/util.js";
|
||||
import { parseXFAPath } from "./core_utils.js";
|
||||
import { SimpleXMLParser } from "./xml_parser.js";
|
||||
|
||||
function decodeString(str) {
|
||||
try {
|
||||
return stringToUTF8String(str);
|
||||
} catch (ex) {
|
||||
warn(`UTF-8 decoding failed: "${ex}".`);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
class DatasetXMLParser extends SimpleXMLParser {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
@ -60,10 +70,10 @@ class DatasetReader {
|
||||
|
||||
const first = node.firstChild;
|
||||
if (first && first.nodeName === "value") {
|
||||
return node.children.map(child => child.textContent);
|
||||
return node.children.map(child => decodeString(child.textContent));
|
||||
}
|
||||
|
||||
return node.textContent;
|
||||
return decodeString(node.textContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user