Fix "URI malformed" crashes on Windows
This commit is contained in:
parent
a4a27724bf
commit
3306c82992
3 changed files with 21 additions and 4 deletions
|
@ -26,8 +26,25 @@ function _urlToPath(targetUrl, options = {}) {
|
|||
|
||||
function _createFileHandler({ userDataPath, installPath, isWindows }) {
|
||||
return (request, callback) => {
|
||||
let targetPath;
|
||||
try {
|
||||
targetPath = _urlToPath(request.url, { isWindows });
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err && typeof err.message === 'string'
|
||||
? err.message
|
||||
: 'no error message';
|
||||
console.log(
|
||||
`Warning: denying request because of an error: ${errorMessage}`
|
||||
);
|
||||
|
||||
// This is an "invalid URL" error. See [Chromium's net error list][0].
|
||||
//
|
||||
// [0]: https://source.chromium.org/chromium/chromium/src/+/master:net/base/net_error_list.h;l=563;drc=a836ee9868cf1b9673fce362a82c98aba3e195de
|
||||
return callback({ error: -300 });
|
||||
}
|
||||
// normalize() is primarily useful here for switching / to \ on windows
|
||||
const target = path.normalize(_urlToPath(request.url, { isWindows }));
|
||||
const target = path.normalize(targetPath);
|
||||
// here we attempt to follow symlinks to the ultimate final path, reflective of what
|
||||
// we do in main.js on userDataPath and installPath
|
||||
const realPath = fs.existsSync(target) ? fs.realpathSync(target) : target;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// Copyright 2020-2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React from 'react';
|
||||
|
@ -26,7 +26,7 @@ export const CallBackgroundBlur = ({
|
|||
<div
|
||||
className="module-calling__background--blur"
|
||||
style={{
|
||||
backgroundImage: `url("${avatarPath}")`,
|
||||
backgroundImage: `url('${encodeURI(avatarPath)}')`,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
@ -474,7 +474,7 @@ function ThumbnailImage({
|
|||
<div
|
||||
className="module-quote__icon-container"
|
||||
style={
|
||||
loadedSrc ? { backgroundImage: `url('${escape(loadedSrc)}')` } : {}
|
||||
loadedSrc ? { backgroundImage: `url('${encodeURI(loadedSrc)}')` } : {}
|
||||
}
|
||||
>
|
||||
{children}
|
||||
|
|
Loading…
Reference in a new issue