aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorSebastian C <sebsebmc@gmail.com>2025-04-11 12:59:03 -0500
committerGitHub <noreply@github.com>2025-04-11 17:59:03 +0000
commit2d2cfade3633d0858c052af20535771c949a6529 (patch)
tree402a3f0692d28121367bf75a5af8bfe0c167d6c7 /components/script
parent5c7cf7aed6a7fe108d34feac6d1e13e4bfcbbbaf (diff)
downloadservo-2d2cfade3633d0858c052af20535771c949a6529.tar.gz
servo-2d2cfade3633d0858c052af20535771c949a6529.zip
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>
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/file.rs9
-rw-r--r--components/script/dom/formdata.rs3
2 files changed, 7 insertions, 5 deletions
diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs
index 14a0ce68094..b80b02b0d0e 100644
--- a/components/script/dom/file.rs
+++ b/components/script/dom/file.rs
@@ -108,6 +108,10 @@ impl File {
pub(crate) fn file_type(&self) -> String {
self.blob.type_string()
}
+
+ pub(crate) fn get_modified(&self) -> SystemTime {
+ self.modified
+ }
}
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(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());
Ok(File::new_with_proto(
global,
proto,
BlobImpl::new_from_bytes(bytes, type_string),
- replaced_filename,
+ filename,
modified,
can_gc,
))
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs
index 1082a202f34..7703ecb0e76 100644
--- a/components/script/dom/formdata.rs
+++ b/components/script/dom/formdata.rs
@@ -275,12 +275,13 @@ impl FormData {
};
let bytes = blob.get_bytes().unwrap_or_default();
+ let last_modified = blob.downcast::<File>().map(|file| file.get_modified());
File::new(
&self.global(),
BlobImpl::new_from_bytes(bytes, blob.type_string()),
name,
- None,
+ last_modified,
can_gc,
)
}