Commit 095fbe8e by murtaugh

fixed an overly greedy regular expression in fixfilelinks

parent 2b47fbaf
......@@ -24,7 +24,7 @@ def fixurlfilelinks (src, wiki, timestamp=None, phpuploader=None, user=None):
return m.group(0)
else:
return "[[{0}{1}]]".format(page.name, m.group(2) or "")
return re.sub(r"\[\[(?:File|Fichier|Image)\:(https?\://.+?)(\|.+)?\]\]", linksub, src)
return re.sub(r"\[\[(?:File|Fichier|Image)\:(https?\://.+?)(\|.*?)?\]\]", linksub, src)
def fixlinks (page, wiki, phpuploader=None, user=None):
print ("fixlinks {0}".format(page.name), file=sys.stderr)
......
url = "http://i.creativecommons.org/l/by-nc-nd/2.0/be/80x15.png"
import re
from urllib.request import Request, urlopen
with open("m/scripts/mediawikifixbrokenfilelinks.test.txt") as f:
src = f.read()
print (re.sub(r"\[\[(?:File|Fichier|Image)\:(https?\://.+?)(\|.*?)?\]\]", "*", src))
# f = urlopen(url)
f = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
print (f)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment