diff options
Diffstat (limited to 'uriloader/exthandler/nsExternalHelperAppService.cpp')
-rw-r--r-- | uriloader/exthandler/nsExternalHelperAppService.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 4573e28470..72925c2fc8 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -3486,8 +3486,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; @@ -3669,6 +3669,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(); |