# HG changeset patch # User HackBot # Date 1487453905 0 # Node ID 8c93629c539474491d480c750d28aaf0eec3dc07 # Parent 024b7442d847d2187f0a1a494cf28da1de61748f fetch bin/edit http://hackego.esolangs.org/get/bin/edit diff -r 024b7442d847 -r 8c93629c5394 bin/edit --- a/bin/edit Sat Feb 18 19:02:24 2017 +0000 +++ b/bin/edit Sat Feb 18 21:38:25 2017 +0000 @@ -1,9 +1,12 @@ #!/usr/bin/env python -import sys, os, urllib +import sys, os.path, re, urllib if len(sys.argv) < 2: - print "usage: edit " - sys.exit(1) + sys.exit('http://hackego.esolangs.org/edit/') -print "http://slbkbs.org:5196/edit?path=" + urllib.quote(os.path.realpath(sys.argv[1])) +f = os.path.realpath(sys.argv[1]) +f = re.sub(r"^/+hackenv/", "", f) +if re.match(r"/|\.hg(?:/|ignore$|$)",f): + sys.exit("File is not editable.") +print 'http://hackego.esolangs.org/edit/' + urllib.quote(f)