Fix CGIFormData to actually store file-upload part content
File-upload parts (Content-Disposition with filename=) were unconditionally flagged currentSkip and discarded at PART_BOUNDARY, so every <field type="file"> upload site (track audio, presets, project icons) only ever received an empty value via $[fieldname], never the real uploaded bytes.
This commit is contained in:
1 parent
78c45d378c
commit
29db853706
2 files changed
+9
-5
No files matched your search
+9
-4
@@ -24,8 +24,6 @@ namespace coreutils {
|
||||
MString disposition = fields[MString("Content-Disposition")];
|
||||
ZString dz(disposition.getData(), disposition.getLength());
|
||||
|
||||
currentSkip = (dz.find(ZString("filename=\"")) != -1);
|
||||
|
||||
int namePos = dz.find(ZString("name=\""));
|
||||
if (namePos != -1) {
|
||||
ZString afterName = dz.substring(namePos + 6);
|
||||
@@ -117,10 +115,17 @@ namespace coreutils {
|
||||
if (pos < 0)
|
||||
return Status::INCOMPLETE;
|
||||
char *bodyEnd = buffer.getCursor();
|
||||
if (!currentSkip && currentName.getLength() > 0)
|
||||
// A part whose Content-Disposition includes filename="..."
|
||||
// (a real <input type="file">) used to be silently discarded
|
||||
// here (currentSkip) rather than stored like any other part -
|
||||
// every existing <field type="file"> upload (track audio,
|
||||
// presets, project icons) has therefore never actually
|
||||
// received real file content via $[fieldname], only ever an
|
||||
// empty value. Storing it the same way as any other part is
|
||||
// exactly what those call sites already assume.
|
||||
if (currentName.getLength() > 0)
|
||||
storeValue(currentName, MString(ZString(bodyStart, bodyEnd - bodyStart)));
|
||||
currentName = MString();
|
||||
currentSkip = false;
|
||||
state = PART_BOUNDARY;
|
||||
return Status::DATA_AVAIL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user