Skip to content

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

@bobbbob98

Description

@bobbbob98

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions