##// END OF EJS Templates
hgweb: simplify internal staticfile return codes
Mads Kiilerich -
r18645:76ff3a71 default
parent child Browse files
Show More
@@ -129,7 +129,7 b' def staticfile(directory, fname, req):'
129 for part in parts:
129 for part in parts:
130 if (part in ('', os.curdir, os.pardir) or
130 if (part in ('', os.curdir, os.pardir) or
131 os.sep in part or os.altsep is not None and os.altsep in part):
131 os.sep in part or os.altsep is not None and os.altsep in part):
132 return ""
132 return
133 fpath = os.path.join(*parts)
133 fpath = os.path.join(*parts)
134 if isinstance(directory, str):
134 if isinstance(directory, str):
135 directory = [directory]
135 directory = [directory]
@@ -144,7 +144,6 b' def staticfile(directory, fname, req):'
144 data = fp.read()
144 data = fp.read()
145 fp.close()
145 fp.close()
146 req.respond(HTTP_OK, ct, body=data)
146 req.respond(HTTP_OK, ct, body=data)
147 return ""
148 except TypeError:
147 except TypeError:
149 raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
148 raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
150 except OSError, err:
149 except OSError, err:
@@ -197,7 +197,8 b' class hgwebdir(object):'
197 if isinstance(tp, str):
197 if isinstance(tp, str):
198 tp = [tp]
198 tp = [tp]
199 static = [os.path.join(p, 'static') for p in tp]
199 static = [os.path.join(p, 'static') for p in tp]
200 return (staticfile(static, fname, req),)
200 staticfile(static, fname, req)
201 return []
201
202
202 # top-level index
203 # top-level index
203 elif not virtual:
204 elif not virtual:
@@ -842,7 +842,8 b' def static(web, req, tmpl):'
842 if isinstance(tp, str):
842 if isinstance(tp, str):
843 tp = [tp]
843 tp = [tp]
844 static = [os.path.join(p, 'static') for p in tp]
844 static = [os.path.join(p, 'static') for p in tp]
845 return [staticfile(static, fname, req)]
845 staticfile(static, fname, req)
846 return []
846
847
847 def graph(web, req, tmpl):
848 def graph(web, req, tmpl):
848
849
General Comments 0
You need to be logged in to leave comments. Login now