mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 15:48:06 +02:00
Strip null
(\x00) characters from the URLs in LinkAnnotations (issue 6832)
Apparently some PDF files can have annotations with `URI` entries ending with `null` characters, thus breaking the links. To handle this edge-case of bad PDFs, this patch moves the already existing utility function from `ui_utils.js` into `util.js`, in order to fix those URLs. Fixes 6832.
This commit is contained in:
parent
4e9ea35eee
commit
97c10e9c08
7 changed files with 33 additions and 25 deletions
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals getFileName, removeNullCharacters */
|
||||
/* globals getFileName, PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -89,7 +89,7 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
|
|||
div.className = 'attachmentsItem';
|
||||
var button = document.createElement('button');
|
||||
this._bindLink(button, item.content, filename);
|
||||
button.textContent = removeNullCharacters(filename);
|
||||
button.textContent = PDFJS.removeNullCharacters(filename);
|
||||
div.appendChild(button);
|
||||
this.container.appendChild(div);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals removeNullCharacters */
|
||||
/* globals PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -137,7 +137,7 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
|
|||
div.className = 'outlineItem';
|
||||
var element = document.createElement('a');
|
||||
this._bindLink(element, item);
|
||||
element.textContent = removeNullCharacters(item.title);
|
||||
element.textContent = PDFJS.removeNullCharacters(item.title);
|
||||
div.appendChild(element);
|
||||
|
||||
if (item.items.length > 0) {
|
||||
|
|
|
@ -23,12 +23,6 @@ var MAX_AUTO_SCALE = 1.25;
|
|||
var SCROLLBAR_PADDING = 40;
|
||||
var VERTICAL_PADDING = 5;
|
||||
|
||||
var NullCharactersRegExp = /\x00/g;
|
||||
|
||||
function removeNullCharacters(str) {
|
||||
return str.replace(NullCharactersRegExp, '');
|
||||
}
|
||||
|
||||
function getFileName(url) {
|
||||
var anchor = url.indexOf('#');
|
||||
var query = url.indexOf('?');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue