mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #14268 from calixteman/outline
Remove non-displayable chars from outline title (#14267)
This commit is contained in:
commit
85c6dd59ce
6 changed files with 38 additions and 3 deletions
|
@ -566,16 +566,20 @@ class AbortException extends BaseException {
|
|||
}
|
||||
}
|
||||
|
||||
const NullCharactersRegExp = /\x00/g;
|
||||
const NullCharactersRegExp = /\x00+/g;
|
||||
const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
|
||||
|
||||
/**
|
||||
* @param {string} str
|
||||
*/
|
||||
function removeNullCharacters(str) {
|
||||
function removeNullCharacters(str, replaceInvisible = false) {
|
||||
if (typeof str !== "string") {
|
||||
warn("The argument for removeNullCharacters must be a string.");
|
||||
return str;
|
||||
}
|
||||
if (replaceInvisible) {
|
||||
str = str.replace(InvisibleCharactersRegExp, " ");
|
||||
}
|
||||
return str.replace(NullCharactersRegExp, "");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue