Sun Jul 3 21:39:57 UTC 2005 Alberto Bertogli * Support repos with semi-strange characters. Implement support for repo names with semi-strange characters (ie. at least - and _). It could use more improvement, but it'll do for most repos. diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi --- old-darcsweb/darcsweb.cgi 2015-04-15 14:54:36.000000000 +0000 +++ new-darcsweb/darcsweb.cgi 2015-04-15 14:54:36.000000000 +0000 @@ -15,6 +15,7 @@ import stat import cgi import cgitb; cgitb.enable() +import urllib import xml.sax from xml.sax.saxutils import escape @@ -1118,7 +1119,7 @@ else: print '' alt = not alt print """ -%(name)s +%(dname)s %(desc)s summary | shortlog | @@ -1128,7 +1129,8 @@ """ % { 'myname': all_configs.base.myname, - 'name': name, + 'dname': name, + 'name': urllib.quote(name), 'desc': shorten_str(desc, 60) } print "" @@ -1146,12 +1148,12 @@ break else: # not found - raise + raise "RepoNotFound", name # fill the configuration base = all_configs.base config.myname = base.myname - config.myreponame = base.myname + '?r=' + name + config.myreponame = base.myname + '?r=' + urllib.quote(name) config.myurl = base.myurl config.darcslogo = base.darcslogo config.darcsfav = base.darcsfav @@ -1175,7 +1177,7 @@ sys.exit(0) # get the repo configuration and fill the config class -current_repo = form['r'].value +current_repo = urllib.unquote(form['r'].value) fill_config(current_repo) diff -rN -u old-darcsweb/mkconfig.py new-darcsweb/mkconfig.py --- old-darcsweb/mkconfig.py 2015-04-15 14:54:36.000000000 +0000 +++ new-darcsweb/mkconfig.py 2015-04-15 14:54:36.000000000 +0000 @@ -26,12 +26,24 @@ import sys import os +import string +import urllib def help(): print "Error: wrong parameter count" print __doc__ +def filter_class(s): + "Filter s so the new string can be used as a class name." + allowed = string.ascii_letters + string.digits + '_' + l = [c for c in s if c in allowed] + return string.join(l, "") + +def filter_url(s): + "Filter s so the new string can be used in a raw url." + return urllib.quote_plus(s, ':/') + # check parameters if len(sys.argv) != 5: @@ -48,17 +60,18 @@ continue s = \ """ -class %(name)s: +class %(classname)s: reponame = '%(name)s' repodesc = '%(desc)s' repodir = '%(dir)s' repourl = '%(url)s' repoencoding = '%(encoding)s' """ % { + 'classname': filter_class(d), 'name': d, 'desc': basedesc.replace('NAME', d), 'dir': os.path.abspath(basepath + '/' + d), - 'url': baseurl.replace('NAME', d), + 'url': filter_url(baseurl.replace('NAME', d)), 'encoding': baseencoding, } print s