pallets / flask

The Python micro framework for building web applications.
https://flask.palletsprojects.com
BSD 3-Clause "New" or "Revised" License
67.87k stars 16.2k forks source link

Flask incorrectly parses chained query parameters #5519

Closed alemiherbert closed 3 months ago

alemiherbert commented 3 months ago

When accessing the /test route with both category and location query parameters (http://localhost:5000/test?category=fish&location=water), Flask correctly parses category but ignores location.

Steps to Reproduce

Access the URL http://localhost:5000/test?category=fish&location=water. Expected behavior: Both category and location parameters should be correctly parsed by Flask. Actual behavior: Flask parses category correctly ("excavator"), but location is ignored.

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route("/test")
def test():
    category = request.args.get("category")
    location = request.args.get("location")
    return {"category": category, "location": location}

if __name__ == "__main__":
    app.run(debug=True)

Expected:

{
    "category": "fish",
    "location": "water"
}

Got:

{
    "category": "fish",
    "location": null
}

Environment:

davidism commented 3 months ago

I can't reproduce the issue with the information provided. Running the example gives the expected output.