Mercurial > moin > 1.9
changeset 5286:668606f6a255
Roundtripping works now for PDF, Doc, ...from GUI editor to text editor and vice versa.
author | Josef Meier <jo.meier@gmx.de> |
---|---|
date | Mon, 16 Nov 2009 02:30:27 +0100 |
parents | be3d5338f0a3 |
children | ad509ff9d8c5 |
files | MoinMoin/converter/text_html_text_moin_wiki.py |
diffstat | 1 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py Mon Nov 16 02:35:47 2009 +0100 +++ b/MoinMoin/converter/text_html_text_moin_wiki.py Mon Nov 16 02:30:27 2009 +0100 @@ -8,14 +8,16 @@ import re, os import xml.dom.minidom # HINT: the nodes in parse result tree need .has_key(), "x in ..." does not work +import urlparse from xml.dom import Node from MoinMoin import config, wikiutil from MoinMoin.error import ConvertError - +from werkzeug.utils import url_decode from MoinMoin.parser.text_moin_wiki import Parser as WikiParser interwiki_re = re.compile(WikiParser.interwiki_rule, re.VERBOSE|re.UNICODE) + # Portions (C) International Organization for Standardization 1986 # Permission to copy in any form is granted for use with # conforming SGML systems and applications as defined in @@ -1367,14 +1369,27 @@ markup = '' data = attrs.pop('data', None) if data: - data = wikiutil.url_unquote(data) + scheme, netloc, path, params, query, fragment = urlparse.urlparse(data) + args = url_decode(query) + action = args.get("action") + attachname = args.get("target") + + if (not scheme and not netloc # same server (local attachment!) + and path and action == 'AttachFile' and attachname): + scriptname = self.request.script_root or "/" + pagename = path[len(scriptname):].lstrip("/") + pagename = wikiutil.url_unquote(pagename) + + if pagename != self.request.page.page_name: + attachname = "%s/%s" % (pagename, attachname) + data = "attachment:%s" % attachname desc = self.get_desc(node.childNodes) if desc: desc = '|' + desc - params = ','.join(['%s="%s"' % (k, v) for k, v in attrs.items()]) - # if k in ('width', 'height', )]) + # Exlude 'type' attribute cause it generates a 'key already present' error. + params = ','.join(['%s="%s"' % (k, v) for k, v in attrs.items() if not k in ('type', )]) if params: params = '|' + params if not desc: