File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,12 @@ def do_GET(self):
127127 else :
128128 # Handle files here.
129129 word = sp
130- page = get_static_page_by_path (usp )
130+ try :
131+ page = get_static_page_by_path (usp )
132+ except FileNotFoundError :
133+ page = "Internal error: Path for static page '%s' is unknown" % usp
134+ # Set type to plain to prevent XSS by printing the path as HTML
135+ type = "text/plain"
131136 elif sp .startswith ("search" ):
132137 # This doesn't seem to work with MWEs.
133138 type = "text/html"
@@ -816,8 +821,7 @@ def get_static_page_by_path(path):
816821 return get_static_web_help_page ()
817822 elif path == "wx_help.html" :
818823 return get_static_wx_help_page ()
819- else :
820- return "Internal error: Path for static page '%s' is unknown" % path
824+ raise FileNotFoundError ()
821825
822826
823827def get_static_web_help_page ():
You can’t perform that action at this time.
0 commit comments