Fixed issue 625: SVG Data URLs fail to load when ending with an equals (=) character
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1786 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
e936e96078
commit
884e92dc3a
|
@ -207,10 +207,15 @@
|
||||||
|
|
||||||
svgEditor.setConfig(urldata);
|
svgEditor.setConfig(urldata);
|
||||||
|
|
||||||
// FIXME: This is null if Data URL ends with '='.
|
|
||||||
var src = urldata.source;
|
var src = urldata.source;
|
||||||
var qstr = $.param.querystring();
|
var qstr = $.param.querystring();
|
||||||
|
|
||||||
|
if(!src) { // urldata.source may have been null if it ended with '='
|
||||||
|
if(qstr.indexOf('source=data:' >= 0)) {
|
||||||
|
src = qstr.match(/source=(data:[^&]*)/)[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(src) {
|
if(src) {
|
||||||
if(src.indexOf("data:") === 0) {
|
if(src.indexOf("data:") === 0) {
|
||||||
// plusses get replaced by spaces, so re-insert
|
// plusses get replaced by spaces, so re-insert
|
||||||
|
@ -4086,7 +4091,7 @@
|
||||||
if(f.files.length==1) {
|
if(f.files.length==1) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onloadend = function(e) {
|
reader.onloadend = function(e) {
|
||||||
svgCanvas.setSvgString(e.target.result);
|
loadSvgString(e.target.result);
|
||||||
updateCanvas();
|
updateCanvas();
|
||||||
};
|
};
|
||||||
reader.readAsText(f.files[0]);
|
reader.readAsText(f.files[0]);
|
||||||
|
@ -4401,6 +4406,12 @@
|
||||||
|
|
||||||
var callbacks = [];
|
var callbacks = [];
|
||||||
|
|
||||||
|
function loadSvgString(str) {
|
||||||
|
if(!svgCanvas.setSvgString(str)) {
|
||||||
|
$.alert('Error: Unable to load SVG data.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Editor.ready = function(cb) {
|
Editor.ready = function(cb) {
|
||||||
if(!is_ready) {
|
if(!is_ready) {
|
||||||
callbacks.push(cb);
|
callbacks.push(cb);
|
||||||
|
@ -4418,7 +4429,7 @@
|
||||||
|
|
||||||
Editor.loadFromString = function(str) {
|
Editor.loadFromString = function(str) {
|
||||||
Editor.ready(function() {
|
Editor.ready(function() {
|
||||||
svgCanvas.setSvgString(str);
|
loadSvgString(str);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4428,10 +4439,10 @@
|
||||||
'url': url,
|
'url': url,
|
||||||
'dataType': 'text',
|
'dataType': 'text',
|
||||||
cache: !!cache,
|
cache: !!cache,
|
||||||
success: svgCanvas.setSvgString,
|
success: loadSvgString,
|
||||||
error: function(xhr, stat, err) {
|
error: function(xhr, stat, err) {
|
||||||
if(xhr.responseText) {
|
if(xhr.responseText) {
|
||||||
svgCanvas.setSvgString(xhr.responseText);
|
loadSvgString(xhr.responseText);
|
||||||
} else {
|
} else {
|
||||||
$.alert("Unable to load from URL. Error: \n"+err+'');
|
$.alert("Unable to load from URL. Error: \n"+err+'');
|
||||||
}
|
}
|
||||||
|
@ -4442,10 +4453,9 @@
|
||||||
|
|
||||||
Editor.loadFromDataURI = function(str) {
|
Editor.loadFromDataURI = function(str) {
|
||||||
Editor.ready(function() {
|
Editor.ready(function() {
|
||||||
svgCanvas.setSvgString(str);
|
|
||||||
var pre = 'data:image/svg+xml;base64,';
|
var pre = 'data:image/svg+xml;base64,';
|
||||||
var src = str.substring(pre.length);
|
var src = str.substring(pre.length);
|
||||||
svgCanvas.setSvgString(Utils.decode64(src));
|
loadSvgString(svgCanvas.Utils.decode64(src));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue