Closed eaxle closed 7 years ago
turns out if (!isValidUrl(url, true)) { url = ''; } solved my problem
Please share a PDF file that shows the problem.
@Rob--W I am sorry, I am not allowed.But there are pdfs with relative links to other pdfs in internet.
the value to relative links was false in pdf.worker.js . I set the value to true .This solved my problem
Be careful, the change you proposing might cause cross-site scripting attacks of non-trusted pdfs are served.
It is very hard to fix this issue if no example PDF file is provided, hence I'm closing this as incomplete until a file is provided and there is a possible solution that will have less security implications.
Untitled.pdf master.pdf I tried to replicate the files I was provided and these are the files I could come near to replicate the files.The code That solved my problem is
else if(linkType === 'Launch'){
var urlDict = action.get('F');
if (isDict(urlDict)) {
// We assume that the 'url' is a Filspec dictionary
// and fetch the url without checking any further
url = urlDict.get('F') || '';
console.log(url)
}
if (!isValidUrl(url, true)) {
url = '';
}
var checkIfPdf=url.split(".");
if(checkIfPdf[checkIfPdf.length-1]=='pdf'){
url="?file="+url;
}
data.url = url;
data.dest = action.get('D');
}
and changes were done in :-
else if (linkType === 'GoToR') {
var urlDict = action.get('F');
if (isDict(urlDict)) {
// We assume that the 'url' is a Filspec dictionary
// and fetch the url without checking any further
url = urlDict.get('F') || '';
}
//console.log(url)
// TODO: pdf reference says that GoToR
// can also have 'NewWindow' attribute
if (!isValidUrl(url, true)) {
url = '';
}
var checkIfPdf=url.split(".");
if(checkIfPdf[checkIfPdf.length-1]=='pdf'){
url="?file="+url;
}
data.url = url;
data.dest = action.get('D');
}
Thanks for the information, re-opening.
I believe this file has the same problem:
(any link on the main index gives me 'Warning: unrecognized link type: Launch', while the downloaded version does attempt to load the linked files, failing only because they aren't present locally)
I have a master PDF document that has some relative links to other PDF documents... When I open it locally in Adobe Acrobat Reader, the links works... When I try to open the master document in pdfjs, the links points to itself with '#page=1'.Inspect element shows:(title="" href="#page=1" class="internalLink") for anchor tag
.In fact all the links have same href value.The master pdf file is single page file. In pdf.worker.js,inside LinkAnnotationClosure() function ,inside else if (linkType === 'GoToR') .. I console.log(action.get('F').get('F'))the url when (isDict(urlDict)==true I can see the pdf document name that I want to open.I tried https://github.com/mozilla/pdf.js/issues/3572 and https://github.com/mozilla/pdf.js/issues/1778 in pdf.worker.js but it didn't help.The link Type are Launch and GoToR.The url value goes into invalid url in the code