File tree Expand file tree Collapse file tree 3 files changed +35
-15
lines changed Expand file tree Collapse file tree 3 files changed +35
-15
lines changed Original file line number Diff line number Diff line change @@ -317,6 +317,10 @@ Fixed:
317317 %20. Fixes to allow a url_query method to be applied to
318318 HTMLStringProperty to properly quote string values passed as part of
319319 a url.
320+ - issue2550755: exceptions.NotFound(msg) msg is not reported to user
321+ in cgi. When an invalid column is specified return error code 400
322+ rather than 404. Make error code 400 also return an error message to
323+ the user. Reported by: Bernhard Reiter, analysis, fix by John Rouillard.
320324
3213252016-01-11: 1.5.1
322326
Original file line number Diff line number Diff line change @@ -1256,11 +1256,11 @@ def handle(self):
12561256 props = klass .getprops ()
12571257 for cname in columns :
12581258 if cname not in props :
1259- # TODO raise exceptions.NotFound(.....) does not give message
1260- # so using SeriousError instead
1261- self .client .response_code = 404
1262- raise exceptions .SeriousError (
1263- self ._ ('Column "%(column)s" not found on %(class)s' )
1259+ # use error code 400: Bad Request. Do not use
1260+ # error code 404: Not Found.
1261+ self .client .response_code = 400
1262+ raise exceptions .NotFound (
1263+ self ._ ('Column "%(column)s" not found in %(class)s' )
12641264 % {'column' : cgi .escape (cname ), 'class' : request .classname })
12651265
12661266 # full-text search
Original file line number Diff line number Diff line change @@ -550,16 +550,32 @@ def inner_main(self):
550550 self .response_code = 304
551551 self .header ()
552552 except NotFound , e :
553- self .response_code = 404
554- self .template = '404'
555- try :
556- cl = self .db .getclass (self .classname )
557- self .write_html (self .renderContext ())
558- except KeyError :
559- # we can't map the URL to a class we know about
560- # reraise the NotFound and let roundup_server
561- # handle it
562- raise NotFound (e )
553+ if self .response_code == 400 :
554+ # We can't find a parameter (e.g. property name
555+ # incorrect). Tell the user what was raised.
556+ # Do not change to the 404 template since the
557+ # base url is valid just query args are not.
558+ # copy the page format from SeriousError _str_ exception.
559+ error_page = """
560+ <html><head><title>Roundup issue tracker: An error has occurred</title>
561+ <link rel="stylesheet" type="text/css" href="@@file/style.css">
562+ </head>
563+ <body class="body" marginwidth="0" marginheight="0">
564+ <p class="error-message">%s</p>
565+ </body></html>
566+ """
567+ self .write_html (error_page % str (e ))
568+ else :
569+ self .response_code = 404
570+ self .template = '404'
571+ try :
572+ cl = self .db .getclass (self .classname )
573+ self .write_html (self .renderContext ())
574+ except KeyError :
575+ # we can't map the URL to a class we know about
576+ # reraise the NotFound and let roundup_server
577+ # handle it
578+ raise NotFound (e )
563579 except FormError , e :
564580 self .add_error_message (self ._ ('Form Error: ' ) + str (e ))
565581 self .write_html (self .renderContext ())
You can’t perform that action at this time.
0 commit comments