Mercurial > repo
changeset 10317:024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
author | HackBot |
---|---|
date | Sat, 18 Feb 2017 19:02:24 +0000 |
parents | cfa55b232b54 |
children | 8c93629c5394 |
files | bin/raw-url |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/raw-url Sat Feb 18 19:00:28 2017 +0000 +++ b/bin/raw-url Sat Feb 18 19:02:24 2017 +0000 @@ -1,7 +1,14 @@ #!/usr/bin/env python -import sys, urllib +import sys, os.path, re, urllib if len(sys.argv) <= 1: - print "http://codu.org/projects/hackbot/fshg/" + print "http://hackego.esolangs.org/fshg/" else: - print ("http://codu.org/projects/hackbot/fshg/index.cgi/raw-file/tip/" + - urllib.quote(sys.argv[1])) + f = os.path.abspath(sys.argv[1]) + f = re.sub(r"^/+hackenv/", "", f) + if re.match(r"/|\.hg(?:/|$)",f): + sys.exit("File is outside web-viewable filesystem repository.") + elif re.match(r"tmp(?:/|$)",f): + print ("http://hackego.esolangs.org/" + urllib.quote(f)) + else: + print ("http://hackego.esolangs.org/fshg/index.cgi/raw-file/tip/" + + urllib.quote(f))