void ImportAddressImpl::SanitizeSampleData( nsCString& val) { // remove any line-feeds... val.ReplaceSubstring( "\x0D\x0A", ", "); val.ReplaceChar( 13, ','); val.ReplaceChar( 10, ','); }
nsresult GenerateRandomPathName(nsCString& aOutSalt, uint32_t aLength) { nsresult rv = GenerateRandomName(aOutSalt, aLength); if (NS_FAILED(rv)) return rv; // Base64 characters are alphanumeric (a-zA-Z0-9) and '+' and '/', so we need // to replace illegal characters -- notably '/' aOutSalt.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '_'); return NS_OK; }
void CBrowserView::GetBrowserWindowTitle(nsCString& title) { nsXPIDLString idlStrTitle; if(mBaseWindow) mBaseWindow->GetTitle(getter_Copies(idlStrTitle)); title.AssignWithConversion(idlStrTitle); // Sanitize the title of all illegal characters title.CompressWhitespace(); // Remove whitespace from the ends title.StripChars("\\*|:\"><?"); // Strip illegal characters title.ReplaceChar('.', L'_'); // Dots become underscores title.ReplaceChar('/', L'-'); // Forward slashes become hyphens }
static nsresult Base64urlEncode(const PRUint8* aBytes, PRUint32 aNumBytes, nsCString& _result) { // SetLength does not set aside space for NULL termination. PL_Base64Encode // will not NULL terminate, however, nsCStrings must be NULL terminated. As a // result, we set the capacity to be one greater than what we need, and the // length to our desired length. PRUint32 length = (aNumBytes + 2) / 3 * 4; // +2 due to integer math. NS_ENSURE_TRUE(_result.SetCapacity(length + 1), NS_ERROR_OUT_OF_MEMORY); _result.SetLength(length); (void)PL_Base64Encode(reinterpret_cast<const char*>(aBytes), aNumBytes, _result.BeginWriting()); // base64url encoding is defined in RFC 4648. It replaces the last two // alphabet characters of base64 encoding with '-' and '_' respectively. _result.ReplaceChar('+', '-'); _result.ReplaceChar('/', '_'); return NS_OK; }
void nsTextAddress::SanitizeSingleLine( nsCString& val) { val.ReplaceSubstring( "\x0D\x0A", ", "); val.ReplaceChar( 13, ' '); val.ReplaceChar( 10, ' '); }
void nsEudoraAddress::SanitizeValue( nsCString& val) { val.ReplaceSubstring( "\n", ", "); val.ReplaceChar( 13, ','); val.ReplaceChar( 10, ','); }