diff options
author | Moonchild <moonchild@palemoon.org> | 2020-08-13 12:10:54 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-08-13 12:10:54 +0000 |
commit | 11285cd0d6ef7de80d22187b99376602ed547214 (patch) | |
tree | 034c72eea2e7838b08abd00f37acf8e3c9e97949 /netwerk/base | |
parent | e1e535c1c6372f95b4a14b6a00b6d6e7be400c3b (diff) | |
parent | d3383327a749ddb5c0626146c6f83bdfa3ea9936 (diff) | |
download | UXP-11285cd0d6ef7de80d22187b99376602ed547214.tar UXP-11285cd0d6ef7de80d22187b99376602ed547214.tar.gz UXP-11285cd0d6ef7de80d22187b99376602ed547214.tar.lz UXP-11285cd0d6ef7de80d22187b99376602ed547214.tar.xz UXP-11285cd0d6ef7de80d22187b99376602ed547214.zip |
Merge branch 'master' into es-modules-work
Diffstat (limited to 'netwerk/base')
-rw-r--r-- | netwerk/base/nsBaseChannel.cpp | 6 | ||||
-rw-r--r-- | netwerk/base/nsStandardURL.cpp | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 2575fac04..51caa546e 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -579,6 +579,12 @@ NS_IMETHODIMP nsBaseChannel::SetContentDispositionFilename(const nsAString &aContentDispositionFilename) { mContentDispositionFilename = new nsString(aContentDispositionFilename); + + // For safety reasons ensure the filename doesn't contain null characters and + // replace them with underscores. We may later pass the extension to system + // MIME APIs that expect null terminated strings. + mContentDispositionFilename->ReplaceChar(char16_t(0), '_'); + return NS_OK; } diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index 81b485502..1866c1037 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -2747,12 +2747,16 @@ nsStandardURL::SetFilePath(const nsACString &input) return SetSpec(spec); } - else if (mPath.mLen > 1) { + + if (mPath.mLen > 1) { mSpec.Cut(mPath.mPos + 1, mFilepath.mLen - 1); // left shift query, and ref ShiftFromQuery(1 - mFilepath.mLen); + // One character for '/', and if we have a query or ref we add their
+ // length and one extra for each '?' or '#' characters
+ mPath.mLen = 1 + (mQuery.mLen >= 0 ? (mQuery.mLen + 1) : 0) + + (mRef.mLen >= 0 ? (mRef.mLen + 1) : 0); // these contain only a '/' - mPath.mLen = 1; mDirectory.mLen = 1; mFilepath.mLen = 1; // these are no longer defined |