changeset 645:b3c95c5e8630

svg_edit: svgutils.js reverted to 634:7fe9c706fdb2
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 05 Feb 2015 19:17:13 +0100
parents 9661092d0444
children 815a86c7fbf1
files data/plugin/action/SvgEditor.py htdocs/svg-edit/editor/sanitize.js htdocs/svg-edit/editor/svgedit.compiled.js htdocs/svg-edit/editor/svgutils.js
diffstat 4 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/SvgEditor.py	Thu Feb 05 18:38:39 2015 +0100
+++ b/data/plugin/action/SvgEditor.py	Thu Feb 05 19:17:13 2015 +0100
@@ -10,6 +10,7 @@
     @copyright: 2009-2010 by MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
 """
+import re
 from MoinMoin import config, wikiutil
 from MoinMoin.action import AttachFile, do_show
 from MoinMoin.Page import Page
@@ -91,9 +92,12 @@
             attach_dir = AttachFile.getAttachDir(request, pagename, create=1)
             # save file
             fpath = AttachFile.getFilename(request, pagename, target).encode(config.charset)
-            f = open(fpath, 'w')
-            f.write(filecontent.decode('base_64'))
-            f.close()
+            content = filecontent.decode('base_64')
+            print content
+            p = re.compile(r""" xlink:href""")
+            new_content = p.sub(' target="_blank" xlink:href', content)
+            with open(fpath, 'w') as f:
+                f.write(new_content)
 
         url = Page(request, pagename).url(request)
         request.http_redirect(url)
--- a/htdocs/svg-edit/editor/sanitize.js	Thu Feb 05 18:38:39 2015 +0100
+++ b/htdocs/svg-edit/editor/sanitize.js	Thu Feb 05 19:17:13 2015 +0100
@@ -26,7 +26,7 @@
 // this defines which elements and attributes that we support
 var svgWhiteList_ = {
   // SVG Elements
-  "a": ["class", "clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "id", "mask", "opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform", "xlink:href", "xlink:title"],
+  "a": ["class", "clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "id", "mask", "opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "target", "transform", "xlink:href", "xlink:title"],
   "circle": ["class", "clip-path", "clip-rule", "cx", "cy", "fill", "fill-opacity", "fill-rule", "filter", "id", "mask", "opacity", "r", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform"],
   "clipPath": ["class", "clipPathUnits", "id"],
   "defs": [],
--- a/htdocs/svg-edit/editor/svgedit.compiled.js	Thu Feb 05 18:38:39 2015 +0100
+++ b/htdocs/svg-edit/editor/svgedit.compiled.js	Thu Feb 05 19:17:13 2015 +0100
@@ -39,8 +39,8 @@
 w={};w.width=g.width;w.height=g.height;w.x=g.x+parseFloat(q.getAttribute("x")||0);w.y=g.y+parseFloat(q.getAttribute("y")||0);g=w}else if(~o.indexOf(w))try{g=q.getBBox()}catch(A){q=$(q).closest("foreignObject");if(q.length)try{g=q[0].getBBox()}catch(p){g=null}else g=null}}if(g)g=svgedit.utilities.bboxToObj(g);return g};svgedit.utilities.getRotationAngle=function(g,q){var w=g||c.getSelectedElements()[0];w=svgedit.transformlist.getTransformList(w);if(!w)return 0;var D=w.numberOfItems,u;for(u=0;u<D;++u){var A=
 w.getItem(u);if(A.type==4)return q?A.angle*Math.PI/180:A.angle}return 0};svgedit.utilities.getRefElem=function(g){return svgedit.utilities.getElem(svgedit.utilities.getUrlFromAttr(g).substr(1))};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(g){return e.querySelector("#"+g)}:svgedit.browser.supportsXpath()?function(g){return h.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+g+'"]',s,function(){return svgedit.NS.SVG},9,null).singleNodeValue}:function(g){return $(e).find("[id="+
 g+"]")[0]};svgedit.utilities.assignAttributes=function(g,q,w,D){w||(w=0);svgedit.browser.isOpera()||e.suspendRedraw(w);for(var u in q)if(w=u.substr(0,4)==="xml:"?I.XML:u.substr(0,6)==="xlink:"?I.XLINK:null)g.setAttributeNS(w,u,q[u]);else D?svgedit.units.setUnitAttr(g,u,q[u]):g.setAttribute(u,q[u]);svgedit.browser.isOpera()||e.unsuspendRedraw(null)};svgedit.utilities.cleanupElement=function(g){var q=e.suspendRedraw(60),w={"fill-opacity":1,"stop-opacity":1,opacity:1,stroke:"none","stroke-dasharray":"none",
-"stroke-linejoin":"miter","stroke-linecap":"butt","stroke-opacity":1,"stroke-width":1,rx:0,ry:0},D;for(D in w){var u=w[D];g.getAttribute(D)==u&&g.removeAttribute(D)}e.unsuspendRedraw(q)};svgedit.utilities.snapToGrid=function(g){var q=c.getSnappingStep(),w=c.getBaseUnit();if(w!=="px")q*=svgedit.units.getTypeMap()[w];return g=Math.round(g/q)*q};svgedit.utilities.preg_quote=function(g,q){return String(g).replace(RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\"+(q||"")+"-]","g"),"\\$&")}})();(function(){if(!svgedit.sanitize)svgedit.sanitize={};var a=svgedit.NS,I=svgedit.getReverseNS(),o={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask",
-"opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class","clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin",
+"stroke-linejoin":"miter","stroke-linecap":"butt","stroke-opacity":1,"stroke-width":1,rx:0,ry:0},D;for(D in w){var u=w[D];g.getAttribute(D)==u&&g.removeAttribute(D)}e.unsuspendRedraw(q)};svgedit.utilities.snapToGrid=function(g){var q=c.getSnappingStep(),w=c.getBaseUnit();if(w!=="px")q*=svgedit.units.getTypeMap()[w];return g=Math.round(g/q)*q};svgedit.utilities.preg_quote=function(g,q){return String(g).replace(RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\"+(q||"")+"-]","g"),"\\$&")}})();(function(){if(!svgedit.sanitize)svgedit.sanitize={};var a=svgedit.NS,I=svgedit.getReverseNS(),o={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","target","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id",
+"mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class","clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin",
 "stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters","filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display",
 "fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class",
 "clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id",
--- a/htdocs/svg-edit/editor/svgutils.js	Thu Feb 05 18:38:39 2015 +0100
+++ b/htdocs/svg-edit/editor/svgutils.js	Thu Feb 05 19:17:13 2015 +0100
@@ -351,7 +351,6 @@
 // Sets the given element's xlink:href value
 svgedit.utilities.setHref = function(elem, val) {
 	elem.setAttributeNS(NS.XLINK, 'xlink:href', val);
-	elem.setAttributeNS(NS.XLINK, 'target', '_blank');
 };
 
 // Function: findDefs