Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
This commit is contained in:
@@ -43,9 +43,9 @@ namespace {
|
||||
|
||||
void SendJSWarning(Document* aDocument, const char* aWarningName,
|
||||
const nsTArray<nsString>& aWarningArgs) {
|
||||
nsContentUtils::ReportToConsole(
|
||||
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("HTML"), aDocument,
|
||||
nsContentUtils::eFORMS_PROPERTIES, aWarningName, aWarningArgs);
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "HTML"_ns,
|
||||
aDocument, nsContentUtils::eFORMS_PROPERTIES,
|
||||
aWarningName, aWarningArgs);
|
||||
}
|
||||
|
||||
void RetrieveFileName(Blob* aBlob, nsAString& aFilename) {
|
||||
@@ -142,10 +142,9 @@ nsresult FSURLEncoded::AddNameValuePair(const nsAString& aName,
|
||||
|
||||
// Append data to string
|
||||
if (mQueryString.IsEmpty()) {
|
||||
mQueryString += convName + NS_LITERAL_CSTRING("=") + convValue;
|
||||
mQueryString += convName + "="_ns + convValue;
|
||||
} else {
|
||||
mQueryString += NS_LITERAL_CSTRING("&") + convName +
|
||||
NS_LITERAL_CSTRING("=") + convValue;
|
||||
mQueryString += "&"_ns + convName + "="_ns + convValue;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -255,7 +254,7 @@ nsresult FSURLEncoded::GetEncodedSubmission(nsIURI* aURI,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
path += NS_LITERAL_CSTRING("&force-plain-text=Y&body=") + escapedBody;
|
||||
path += "&force-plain-text=Y&body="_ns + escapedBody;
|
||||
|
||||
return NS_MutateURI(aURI).SetPathQueryRef(path).Finalize(aOutURI);
|
||||
} else {
|
||||
@@ -288,8 +287,7 @@ nsresult FSURLEncoded::GetEncodedSubmission(nsIURI* aURI,
|
||||
// mQueryString is empty, nsIURI::SetQuery() will remove the query
|
||||
// component, which is not what we want.
|
||||
rv = NS_MutateURI(aURI)
|
||||
.SetQuery(mQueryString.IsEmpty() ? NS_LITERAL_CSTRING("?")
|
||||
: mQueryString)
|
||||
.SetQuery(mQueryString.IsEmpty() ? "?"_ns : mQueryString)
|
||||
.Finalize(aOutURI);
|
||||
} else {
|
||||
nsAutoCString path;
|
||||
@@ -374,8 +372,7 @@ FSMultipartFormData::~FSMultipartFormData() {
|
||||
nsIInputStream* FSMultipartFormData::GetSubmissionBody(
|
||||
uint64_t* aContentLength) {
|
||||
// Finish data
|
||||
mPostDataChunk +=
|
||||
NS_LITERAL_CSTRING("--") + mBoundary + NS_LITERAL_CSTRING("--" CRLF);
|
||||
mPostDataChunk += "--"_ns + mBoundary + nsLiteralCString("--" CRLF);
|
||||
|
||||
// Add final data input stream
|
||||
AddPostDataStream();
|
||||
@@ -404,10 +401,10 @@ nsresult FSMultipartFormData::AddNameValuePair(const nsAString& aName,
|
||||
// XXX: name parameter should be encoded per RFC 2231
|
||||
// RFC 2388 specifies that RFC 2047 be used, but I think it's not
|
||||
// consistent with MIME standard.
|
||||
mPostDataChunk +=
|
||||
NS_LITERAL_CSTRING("--") + mBoundary + NS_LITERAL_CSTRING(CRLF) +
|
||||
NS_LITERAL_CSTRING("Content-Disposition: form-data; name=\"") + nameStr +
|
||||
NS_LITERAL_CSTRING("\"" CRLF CRLF) + valueStr + NS_LITERAL_CSTRING(CRLF);
|
||||
mPostDataChunk += "--"_ns + mBoundary + nsLiteralCString(CRLF) +
|
||||
"Content-Disposition: form-data; name=\""_ns + nameStr +
|
||||
nsLiteralCString("\"" CRLF CRLF) + valueStr +
|
||||
nsLiteralCString(CRLF);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -518,8 +515,7 @@ nsresult FSMultipartFormData::AddNameDirectoryPair(const nsAString& aName,
|
||||
rv = EncodeVal(dirname16, dirname, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
AddDataChunk(nameStr, dirname, NS_LITERAL_CSTRING("application/octet-stream"),
|
||||
nullptr, 0);
|
||||
AddDataChunk(nameStr, dirname, "application/octet-stream"_ns, nullptr, 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -532,16 +528,14 @@ void FSMultipartFormData::AddDataChunk(const nsACString& aName,
|
||||
// Make MIME block for name/value pair
|
||||
//
|
||||
// more appropriate than always using binary?
|
||||
mPostDataChunk +=
|
||||
NS_LITERAL_CSTRING("--") + mBoundary + NS_LITERAL_CSTRING(CRLF);
|
||||
mPostDataChunk += "--"_ns + mBoundary + nsLiteralCString(CRLF);
|
||||
// XXX: name/filename parameter should be encoded per RFC 2231
|
||||
// RFC 2388 specifies that RFC 2047 be used, but I think it's not
|
||||
// consistent with the MIME standard.
|
||||
mPostDataChunk +=
|
||||
NS_LITERAL_CSTRING("Content-Disposition: form-data; name=\"") + aName +
|
||||
NS_LITERAL_CSTRING("\"; filename=\"") + aFilename +
|
||||
NS_LITERAL_CSTRING("\"" CRLF) + NS_LITERAL_CSTRING("Content-Type: ") +
|
||||
aContentType + NS_LITERAL_CSTRING(CRLF CRLF);
|
||||
mPostDataChunk += "Content-Disposition: form-data; name=\""_ns + aName +
|
||||
"\"; filename=\""_ns + aFilename +
|
||||
nsLiteralCString("\"" CRLF) + "Content-Type: "_ns +
|
||||
aContentType + nsLiteralCString(CRLF CRLF);
|
||||
|
||||
// We should not try to append an invalid stream. That will happen for example
|
||||
// if we try to update a file that actually do not exist.
|
||||
@@ -629,8 +623,7 @@ nsresult FSTextPlain::AddNameValuePair(const nsAString& aName,
|
||||
// XXX This won't work well with a name like "a=b" or "a\nb" but I suppose
|
||||
// text/plain doesn't care about that. Parsers aren't built for escaped
|
||||
// values so we'll have to live with it.
|
||||
mBody.Append(aName + NS_LITERAL_STRING("=") + aValue +
|
||||
NS_LITERAL_STRING(CRLF));
|
||||
mBody.Append(aName + u"="_ns + aValue + NS_LITERAL_STRING(CRLF));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -676,7 +669,7 @@ nsresult FSTextPlain::GetEncodedSubmission(nsIURI* aURI,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
path += NS_LITERAL_CSTRING("&force-plain-text=Y&body=") + escapedBody;
|
||||
path += "&force-plain-text=Y&body="_ns + escapedBody;
|
||||
|
||||
rv = NS_MutateURI(aURI).SetPathQueryRef(path).Finalize(aOutURI);
|
||||
} else {
|
||||
@@ -745,7 +738,7 @@ nsresult EncodingFormSubmission::EncodeVal(const nsAString& aStr,
|
||||
aOut.Adopt(nsLinebreakConverter::ConvertLineBreaks(
|
||||
aOut.get(), nsLinebreakConverter::eLinebreakAny,
|
||||
nsLinebreakConverter::eLinebreakSpace));
|
||||
aOut.ReplaceSubstring(NS_LITERAL_CSTRING("\""), NS_LITERAL_CSTRING("\\\""));
|
||||
aOut.ReplaceSubstring("\""_ns, "\\\""_ns);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
Reference in New Issue
Block a user