cherrypy / cherrypy

CherryPy is a pythonic, object-oriented HTTP framework. https://cherrypy.dev
https://docs.cherrypy.dev
BSD 3-Clause "New" or "Revised" License
1.8k stars 357 forks source link

cherrpypy popargs breaks file extension handling #1988

Open ikus060 opened 1 year ago

ikus060 commented 1 year ago

Sorry to revive this old bug report #1413

I'm using cherrypy v18.8.0 and I still have the same problem. It seams the proposed change never made it to master: https://github.com/cherrypy/cherrypy/commit/403fe604f8053b368b8d6650206e6508ec3b0357

import cherrypy

@cherrypy.popargs('id')
class Person:
    @cherrypy.expose
    def index(self, id=None):
        if id:
            return 'FOO'
        return 'BAR'

    @cherrypy.expose('data.json')
    @cherrypy.tools.json_out()
    def data_json(self, id=None, **kwargs):
        if id:
            return {'a': 'foo'}
        return {'a': 'bar'}

class Root:
    person = Person()

    @cherrypy.expose
    def index(self, id=None):
        return 'index'

cherrypy.quickstart(root=Root())

The following URL return the expected result:

http://127.0.0.1:8080/ http://127.0.0.1:8080/person/ http://127.0.0.1:8080/person/5/ http://127.0.0.1:8080/person/data.json

But the following URL return 404 http://127.0.0.1:8080/person/5/data.json

Simply because the vpath contains '.' that is not replaced by underscore (_)