summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-07-29 01:21:13 +0000
committerMoonchild <moonchild@palemoon.org>2020-07-29 14:28:24 +0000
commita91722be27ce3bd541ca10155fe80d81202785ad (patch)
treeb41bffb348ab3d81cd4a622dedbb575f9780c019 /dom
parent1ef64f9ea3396f29b996da0293f96030bd4ac2a5 (diff)
downloadUXP-a91722be27ce3bd541ca10155fe80d81202785ad.tar
UXP-a91722be27ce3bd541ca10155fe80d81202785ad.tar.gz
UXP-a91722be27ce3bd541ca10155fe80d81202785ad.tar.lz
UXP-a91722be27ce3bd541ca10155fe80d81202785ad.tar.xz
UXP-a91722be27ce3bd541ca10155fe80d81202785ad.zip
[network/dom] Improve sanitization of download filenames.
Diffstat (limited to 'dom')
-rw-r--r--dom/base/nsContentUtils.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index 6a9904bf9..1a3f5b5ca 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -5105,6 +5105,14 @@ nsContentUtils::TriggerLink(nsIContent *aContent, nsPresContext *aPresContext,
fileName.SetIsVoid(true); // No actionable download attribute was found.
}
+ // Sanitize fileNames containing control characters by replacing them with
+ // underscores.
+ if (!fileName.IsVoid()) {
+ for (int i = 0; i < 32; i++) {
+ fileName.ReplaceChar(char16_t(i), '_');
+ }
+ }
+
handler->OnLinkClick(aContent, aLinkURI,
fileName.IsVoid() ? aTargetSpec.get() : EmptyString().get(),
fileName, nullptr, nullptr, aIsTrusted, aContent->NodePrincipal());