diff --git a/servefile b/servefile index 7122f5d..e2bd10b 100755 --- a/servefile +++ b/servefile @@ -330,7 +330,24 @@ class DirListingHandler(FileBaseHandler): self.sendFile(path, head) else: self.send_response(404) + errorMsg = """ +
The requestet URL %s was not found on this server
+Back to / + + """ % self.escapeHTML(urllib.unquote(self.path)) + self.send_header("Content-Length", str(len(errorMsg))) self.end_headers() + if not head: + self.wfile.write(errorMsg) + + def escapeHTML(self, htmlstr): + entities = [("<", "<"), (">", ">")] + for src, dst in entities: + htmlstr = htmlstr.replace(src, dst) + return htmlstr def sendDirectoryListing(self, path, head): """ Generate a directorylisting for path and send it """ @@ -400,8 +417,7 @@ class DirListingHandler(FileBaseHandler):