From d4fc79c74268658c618ebbce1b741e84654bbc5d Mon Sep 17 00:00:00 2001 From: Michael Murtaugh Date: Wed, 1 Apr 2020 19:59:36 +0200 Subject: [PATCH] urlquote/unquote for link rewriting --- dumpwiki.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dumpwiki.py b/dumpwiki.py index 91ea727..9853c58 100644 --- a/dumpwiki.py +++ b/dumpwiki.py @@ -7,6 +7,8 @@ import html5lib from functions import Colors import argparse from xml.etree import ElementTree as ET +from urllib.parse import quote as urlquote, unquote as urlunquote + p = argparse.ArgumentParser(description="Dump wiki files to html", formatter_class=argparse.ArgumentDefaultsHelpFormatter) @@ -37,9 +39,11 @@ def filenameforpage(p): return f def filenameforlink(href): + href = urlunquote(href) if href.startswith("/sandbox/itchwiki/index.php/"): href = href[len("/sandbox/itchwiki/index.php/"):] - return href.replace(' ','_').replace('/', SLASH) + '.html' + href = href.replace(' ','_').replace('/', SLASH) + '.html' + href = urlquote(href) return href def rewritelinks (html):