mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
fix: File to FormData not correctly handling name and lastModified (#36458)
Set File's lastModified when reconstructing from Blob for FormData Remove special character replacement in fileName (spec removed this step) Testing: WPT tests exist Fixes: #22744 (if I undertand the issue correctly the filename issue was already fixed and now this fixes the lastModified part) Signed-off-by: Sebastian C <sebsebmc@gmail.com>
This commit is contained in:
parent
5c7cf7aed6
commit
2d2cfade36
4 changed files with 7 additions and 21 deletions
|
@ -108,6 +108,10 @@ impl File {
|
||||||
pub(crate) fn file_type(&self) -> String {
|
pub(crate) fn file_type(&self) -> String {
|
||||||
self.blob.type_string()
|
self.blob.type_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_modified(&self) -> SystemTime {
|
||||||
|
self.modified
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileMethods<crate::DomTypeHolder> for File {
|
impl FileMethods<crate::DomTypeHolder> for File {
|
||||||
|
@ -132,15 +136,12 @@ impl FileMethods<crate::DomTypeHolder> for File {
|
||||||
.map(|modified| OffsetDateTime::UNIX_EPOCH + Duration::milliseconds(modified))
|
.map(|modified| OffsetDateTime::UNIX_EPOCH + Duration::milliseconds(modified))
|
||||||
.map(Into::into);
|
.map(Into::into);
|
||||||
|
|
||||||
// NOTE: Following behaviour might be removed in future,
|
|
||||||
// see https://github.com/w3c/FileAPI/issues/41
|
|
||||||
let replaced_filename = DOMString::from_string(filename.replace('/', ":"));
|
|
||||||
let type_string = normalize_type_string(blobPropertyBag.type_.as_ref());
|
let type_string = normalize_type_string(blobPropertyBag.type_.as_ref());
|
||||||
Ok(File::new_with_proto(
|
Ok(File::new_with_proto(
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
BlobImpl::new_from_bytes(bytes, type_string),
|
BlobImpl::new_from_bytes(bytes, type_string),
|
||||||
replaced_filename,
|
filename,
|
||||||
modified,
|
modified,
|
||||||
can_gc,
|
can_gc,
|
||||||
))
|
))
|
||||||
|
|
|
@ -275,12 +275,13 @@ impl FormData {
|
||||||
};
|
};
|
||||||
|
|
||||||
let bytes = blob.get_bytes().unwrap_or_default();
|
let bytes = blob.get_bytes().unwrap_or_default();
|
||||||
|
let last_modified = blob.downcast::<File>().map(|file| file.get_modified());
|
||||||
|
|
||||||
File::new(
|
File::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
BlobImpl::new_from_bytes(bytes, blob.type_string()),
|
BlobImpl::new_from_bytes(bytes, blob.type_string()),
|
||||||
name,
|
name,
|
||||||
None,
|
last_modified,
|
||||||
can_gc,
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[File-constructor.any.html]
|
|
||||||
[No replacement when using special character in fileName]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
||||||
[File-constructor.any.worker.html]
|
|
||||||
[No replacement when using special character in fileName]
|
|
||||||
expected: FAIL
|
|
|
@ -1,8 +0,0 @@
|
||||||
[set-blob.any.html]
|
|
||||||
[file with lastModified and custom name]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
||||||
[set-blob.any.worker.html]
|
|
||||||
[file with lastModified and custom name]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue