4040 *
4141 * @author Apache Software Foundation
4242 * @since 1.3
43- * @version $Id: RFC1522Codec.java,v 1.1 2004/03/29 07:59:57 ggregory Exp $
43+ * @version $Id: RFC1522Codec.java,v 1.2 2004/04/09 22:21:43 ggregory Exp $
4444 */
4545abstract class RFC1522Codec {
4646
@@ -99,19 +99,22 @@ protected String decodeText(final String text)
9999 return null ;
100100 }
101101 if ((!text .startsWith ("=?" )) || (!text .endsWith ("?=" ))) {
102- throw new DecoderException ("RFC 1521 violation: malformed encoded content" );
102+ throw new DecoderException ("RFC 1522 violation: malformed encoded content" );
103103 }
104104 int termnator = text .length () - 2 ;
105105 int from = 2 ;
106106 int to = text .indexOf ("?" , from );
107107 if ((to == -1 ) || (to == termnator )) {
108- throw new DecoderException ("RFC 1521 violation: charset token not found" );
108+ throw new DecoderException ("RFC 1522 violation: charset token not found" );
109109 }
110110 String charset = text .substring (from , to );
111+ if (charset .equals ("" )) {
112+ throw new DecoderException ("RFC 1522 violation: charset not specified" );
113+ }
111114 from = to + 1 ;
112115 to = text .indexOf ("?" , from );
113116 if ((to == -1 ) || (to == termnator )) {
114- throw new DecoderException ("RFC 1521 violation: encoding token not found" );
117+ throw new DecoderException ("RFC 1522 violation: encoding token not found" );
115118 }
116119 String encoding = text .substring (from , to );
117120 if (!getEncoding ().equalsIgnoreCase (encoding )) {
@@ -120,9 +123,6 @@ protected String decodeText(final String text)
120123 }
121124 from = to + 1 ;
122125 to = text .indexOf ("?" , from );
123- if ((to == -1 ) || (to != termnator )) {
124- throw new DecoderException ("RFC 1521 violation: encoded content not found" );
125- }
126126 byte [] data = text .substring (from , to ).getBytes (StringEncodings .US_ASCII );
127127 data = doDecoding (data );
128128 return new String (data , charset );
0 commit comments