Exemple #1
0
  @SmallTest
  public void testEncodedWord() {
    final String body = "=?UTF-8?B?Foobar?=";
    DecoderUtil.decodeEncodedWord(body, 0, body.length());

    final String body2 = "=?Foobar";
    DecoderUtil.decodeEncodedWord(body2, 0, body2.length());
  }
Exemple #2
0
  @SmallTest
  public void testEncodedWords() {
    final String body = "=?UTF-8?B?Foobar?=";
    DecoderUtil.decodeEncodedWords(body);

    final String body2 = "=?UTF-8?B?Foobar?==?";
    DecoderUtil.decodeEncodedWords(body2);
  }
Exemple #3
0
 public void setName(String paramString) {
   if (paramString != null) {
     String str = REMOVE_OPTIONAL_DQUOTE.matcher(paramString).replaceAll("$1");
     paramString = DecoderUtil.decodeEncodedWords(UNQUOTE.matcher(str).replaceAll("$1"));
     if (paramString.length() == 0) paramString = null;
   }
   this.mName = paramString;
 }
Exemple #4
0
 /**
  * Generate strings of incresing lenght by taking prefix substrings. For each of them, compare
  * with the decoding of the precomputed base-64 encoding.
  */
 public void testBase64Decode() {
   String testString = "xyza\0\"";
   String base64Encoded[] = {"", "eA==", "eHk=", "eHl6", "eHl6YQ==", "eHl6YQA=", "eHl6YQAi"};
   int len = testString.length();
   for (int i = 1; i <= len; ++i) {
     String encoded = padEncoded(base64Encoded[i]);
     String decoded = DecoderUtil.decodeEncodedWords(encoded);
     String prefix = testString.substring(0, i);
     assertEquals("" + i, prefix, decoded);
   }
 }
 public Field parse(final String name, final String body, final String raw) {
   final String value = DecoderUtil.decodeEncodedWords(body);
   return new UnstructuredField(name, body, raw, value);
 }