Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multipart/form-data broken on new firefox version #257

Open
bobbbob98 opened this issue Feb 24, 2025 · 0 comments
Open

multipart/form-data broken on new firefox version #257

bobbbob98 opened this issue Feb 24, 2025 · 0 comments

Comments

@bobbbob98
Copy link

Multipart forms seem to be broken in new firefox versions, no idea why. It works in chromium, qtwebkit and firefox 128 ESR but it seems like something changed in a new version. I looked at the difference between the form format for between firefox versions but they seem the same. Here's a minimal example:

import prologue

const page = """<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
    <form action="/upload" method="post" enctype="multipart/form-data">
        <input type="file" name="image">
        <button type="submit">Upload</button>
    </form>
</body>
</html>"""

proc form(ctx: Context) {.async.} =
    resp htmlResponse(page)
    
proc upload(ctx: Context) {.async.} =
    try:
        let f = ctx.request.formParams["image"]
        if f.body.len == 0:
            resp "<h1>File upload is empty.</h1>"
        else:
            resp "<h1>Success, filename: " & f.params["filename"] & "</h1>"
    except KeyError:
        resp "<h1>Error, param 'image' not found.</h1>"

var app = newApp()
app.addRoute("/", form)
app.addRoute("/upload", upload, HttpPost)
app.run()

Will always respond with the error on firefox 135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant