- Fix (regression): Imagelib (ensure non-URL relative paths are treated as current origin); variable order (#274)

master
Brett Zamir 2018-09-25 03:32:01 +08:00
parent 459a6b8f89
commit 83aa156353
2 changed files with 21 additions and 11 deletions

View File

@ -52,7 +52,7 @@ var svgEditorExtension_imagelib = (function () {
var decode64 = _ref.decode64,
importLocale = _ref.importLocale,
dropXMLInternalSubset = _ref.dropXMLInternalSubset;
var imagelibStrings, modularVersion, allowedImageLibOrigins, svgEditor, $, uiStrings, svgCanvas, extIconsPath, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, toggleMulti, showBrowser, buttons;
var imagelibStrings, modularVersion, svgEditor, $, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, toggleMulti, showBrowser, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
@ -198,6 +198,10 @@ var svgEditorExtension_imagelib = (function () {
case 6:
imagelibStrings = _context.sent;
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false;
svgEditor = this;
$ = jQuery;
uiStrings = svgEditor.uiStrings, svgCanvas = svgEditor.canvas, extIconsPath = svgEditor.curConfig.extIconsPath;
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(function (_ref3) {
var name = _ref3.name,
@ -210,11 +214,12 @@ var svgEditorExtension_imagelib = (function () {
allowedImageLibOrigins = imagelibStrings.imgLibs.map(function (_ref4) {
var url = _ref4.url;
return new URL(url).origin;
try {
return new URL(url).origin;
} catch (err) {
return location.origin;
}
});
svgEditor = this;
$ = jQuery;
uiStrings = svgEditor.uiStrings, svgCanvas = svgEditor.canvas, extIconsPath = svgEditor.curConfig.extIconsPath;
pending = {};
mode = 's';
multiArr = [];

View File

@ -15,6 +15,12 @@ export default {
const modularVersion = !('svgEditor' in window) ||
!window.svgEditor ||
window.svgEditor.modules !== false;
const svgEditor = this;
const $ = jQuery;
const {uiStrings, canvas: svgCanvas, curConfig: {extIconsPath}} = svgEditor;
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(({name, url, description}) => {
url = url
.replace(/\{path\}/g, extIconsPath)
@ -25,14 +31,13 @@ export default {
return {name, url, description};
});
const allowedImageLibOrigins = imagelibStrings.imgLibs.map(({url}) => {
return new URL(url).origin;
try {
return new URL(url).origin;
} catch (err) {
return location.origin;
}
});
const svgEditor = this;
const $ = jQuery;
const {uiStrings, canvas: svgCanvas, curConfig: {extIconsPath}} = svgEditor;
function closeBrowser () {
$('#imgbrowse_holder').hide();
}