Fix #297 Encode PDF path in viewer to support path containing #

This commit is contained in:
James-Yu 2017-11-03 15:06:55 +08:00
parent e7b0594f14
commit dc18c39298
4 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,9 @@
# Change Log
## [3.6.1] - Unreleased
### Fixed
- (#297) PDF path can contain `#` now.
## [3.6.0] - 2017-11-01
### Added
- (#288) New `latex-workshop.intellisense.surroundCommand.enabled` config to control command surrounding feature.

View File

@ -3,7 +3,7 @@
"displayName": "LaTeX Workshop",
"description": "Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.",
"icon": "icon.png",
"version": "3.6.0",
"version": "3.6.1",
"publisher": "James-Yu",
"license": "MIT",
"homepage": "https://github.com/James-Yu/LaTeX-Workshop",

View File

@ -35,8 +35,10 @@ export class Server {
if (!request.url) {
return
}
request.url = decodeURIComponent(request.url)
if (request.url.indexOf('pdf:') >= 0 && request.url.indexOf('viewer.html') < 0) {
const fileName = decodeURIComponent(request.url).replace('/pdf:', '')
// The second backslash was encoded as %2F, and the first one is prepended by request
const fileName = request.url.replace('//pdf:', '')
try {
const pdfSize = fs.statSync(fileName).size
response.writeHead(200, {'Content-Type': 'application/pdf', 'Content-Length': pdfSize})

View File

@ -5978,7 +5978,7 @@ var pdfjsWebLibs;
return promise;
},
open: function pdfViewOpen(file, args) {
console.log(file)
file = encodeURIComponent(file)
if (arguments.length > 2 || typeof args === 'number') {
return Promise.reject(new Error('Call of open() with obsolete signature.'));
}