1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #8112 from Snuffleupagus/JS-action-newWindow

Support the `newWindow` flag in white-listed `app.launchURL` JavaScript actions (PR 7794 follow-up)
This commit is contained in:
Jonas Jenwald 2017-03-01 21:24:34 +01:00 committed by GitHub
commit 9163a6fba4
2 changed files with 15 additions and 6 deletions

View file

@ -703,12 +703,17 @@ var Catalog = (function CatalogClosure() {
'app.launchURL',
'window.open'
];
var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' +
'\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
var regex = new RegExp(
'^\\s*(' + URL_OPEN_METHODS.join('|').split('.').join('\\.') +
')\\((?:\'|\")([^\'\"]*)(?:\'|\")(?:,\\s*(\\w+)\\)|\\))', 'i');
var jsUrl = regex.exec(stringToPDFString(js), 'i');
if (jsUrl && jsUrl[1]) {
url = jsUrl[1];
var jsUrl = regex.exec(stringToPDFString(js));
if (jsUrl && jsUrl[2]) {
url = jsUrl[2];
if (jsUrl[3] === 'true' && jsUrl[1] === 'app.launchURL') {
resultObj.newWindow = true;
}
break;
}
}