summaryrefslogtreecommitdiffstats
path: root/uriloader/exthandler/nsExternalHelperAppService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'uriloader/exthandler/nsExternalHelperAppService.cpp')
-rw-r--r--uriloader/exthandler/nsExternalHelperAppService.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
index 84dc262561..3577ff2bbf 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -3491,8 +3491,8 @@ void nsExternalHelperAppService::SanitizeFileName(nsAString& aFileName,
nsAutoString fileName(aFileName);
// Replace known invalid characters.
- fileName.ReplaceChar(u"" KNOWN_PATH_SEPARATORS, u'_');
- fileName.ReplaceChar(u"" FILE_ILLEGAL_CHARACTERS, u' ');
+ fileName.ReplaceChar(u"" KNOWN_PATH_SEPARATORS FILE_ILLEGAL_CHARACTERS "%",
+ u'_');
fileName.StripChar(char16_t(0));
const char16_t *startStr, *endStr;
@@ -3674,6 +3674,14 @@ void nsExternalHelperAppService::SanitizeFileName(nsAString& aFileName,
outFileName.Truncate(lastNonTrimmable);
}
+ nsAutoString extension;
+ int32_t dotidx = outFileName.RFind(u".");
+ if (dotidx != -1) {
+ extension = Substring(outFileName, dotidx + 1);
+ extension.StripWhitespace();
+ outFileName = Substring(outFileName, 0, dotidx + 1) + extension;
+ }
+
#ifdef XP_WIN
if (nsLocalFile::CheckForReservedFileName(outFileName)) {
outFileName.Truncate();