mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Move the escapeString
helper function into the worker-thread
Given that this helper function is only used on the worker-thread, there's no reason to duplicate it in both of the `pdf.js` and `pdf.worker.js` files.
This commit is contained in:
parent
e5859e145d
commit
9adc7859c8
6 changed files with 31 additions and 27 deletions
|
@ -313,6 +313,19 @@ function escapePDFName(str) {
|
|||
return buffer.join("");
|
||||
}
|
||||
|
||||
// Replace "(", ")", "\n", "\r" and "\" by "\(", "\)", "\\n", "\\r" and "\\"
|
||||
// in order to write it in a PDF file.
|
||||
function escapeString(str) {
|
||||
return str.replace(/([()\\\n\r])/g, match => {
|
||||
if (match === "\n") {
|
||||
return "\\n";
|
||||
} else if (match === "\r") {
|
||||
return "\\r";
|
||||
}
|
||||
return `\\${match}`;
|
||||
});
|
||||
}
|
||||
|
||||
function _collectJS(entry, xref, list, parents) {
|
||||
if (!entry) {
|
||||
return;
|
||||
|
@ -621,6 +634,7 @@ export {
|
|||
DocStats,
|
||||
encodeToXmlString,
|
||||
escapePDFName,
|
||||
escapeString,
|
||||
getArrayLookupTableFactory,
|
||||
getInheritableProperty,
|
||||
getLookupTableFactory,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue