AnsiString RelaxedCanonicalization::CanonicalizeHeaderValue(AnsiString value) { /* Unfold all header field continuation lines as described in [RFC2822]; in particular, lines with terminators embedded in continued header field values (that is, CRLF sequences followed by WSP) MUST be interpreted without the CRLF. Implementations MUST NOT remove the CRLF at the end of the header field value. */ value.Replace("\r\n ", " "); value.Replace("\r\n\t", " "); /* Convert all sequences of one or more WSP characters to a single SP character. WSP characters here include those before and after a line folding boundary. */ value.Replace("\t ", " "); value.Replace(" \t", " "); while (value.Find(" ") >= 0) value.Replace(" ", " "); /* Delete all WSP characters at the end of each unfolded header field value. */ while (value.EndsWith(" ") || value.EndsWith("\t")) value = value.Mid(0, value.GetLength() -1); /* Delete any WSP characters remaining before and after the colon separating the header field name from the header field value. The colon separator MUST be retained. */ value.Trim(); return value; }
AnsiString Base64::Decode(const char *input, int inputLength) { // base64 encode the signature. MimeCodeBase64 decoder; decoder.SetInput(input, inputLength, false); AnsiString sEncodedValue; decoder.GetOutput(sEncodedValue); // the MIME encoder will insert newlines. We don't want this // here since this is a generic base64 encoder which may be // used in none-mime environments (key encoding anyone?) sEncodedValue.Replace("\r\n", ""); return sEncodedValue; }