- // lax is used for RFC2047 headers; removes restrictions on which chars you can encode
- return s;
- }
- }
-
- // multipart/mixed -- default
- // multipart/parallel -- order of components does not matter
- // multipart/alternative -- same data, different versions
- // multipart/digest -- default content-type of components is message/rfc822
- // message/rfc822 -- FIXME
- // message/partial -- not supported; see RFC 2046, section 5.2.2
- // message/external-body -- not supported; see RFC 2046, section 5.2.3
- // FIXME charsets US-ASCII, ISO-8559-X,
- public static class Content extends org.ibex.js.JSReflection {
- public final String type;
- public final String subtype;
- public final String description;
- public final String id;
- public final String transferEncoding;
- public final String charset;
- public final boolean composite;
- public final boolean alternative;
- public final Hashtable parameters = new Hashtable();
- public Content(String header, String description, String id, String transferEncoding) {
- this.id = id;
- this.description = description;
- this.transferEncoding = transferEncoding;
- if (header == null) { type="text"; subtype="plain"; charset="us-ascii"; alternative=false; composite=false; return; }
- header = header.trim();
- if (header.indexOf('/') == -1) {
- Log.warn(this, "content-type lacks a forward slash: \""+header+"\"");
- header = "text/plain";
- }
- type = header.substring(0, header.indexOf('/')).toLowerCase();
- header = header.substring(header.indexOf('/') + 1);
- subtype = (header.indexOf(';') == -1) ? header.toLowerCase() : header.substring(0, header.indexOf(';')).toLowerCase();
- composite = type != null && (type.equals("message") || type.equals("multipart"));
- alternative = composite && subtype.equals("alternative");
- charset = parameters.get("charset") == null ? "us-ascii" : parameters.get("charset").toString();
- if (header.indexOf(';') == -1) return;
- StringTokenizer st = new StringTokenizer(header.substring(header.indexOf(';') + 1), ";");
- while(st.hasMoreTokens()) {
- String key = st.nextToken().trim();
- if (key.indexOf('=') == -1)
- throw new MailException.Malformed("content-type parameter lacks an equals sign: \""+key+"\"");
- String val = key.substring(key.indexOf('=')+1).trim();
- if (val.startsWith("\"") && val.endsWith("\"")) val = val.substring(1, val.length() - 2);
- key = key.substring(0, key.indexOf('=')+1).toLowerCase();
- parameters.put(key, val);
+ public Part(Fountain all) {
+ this.headers = new Headers(all.getStream());
+ String ctype = headers.get("content-type");
+ this.encoding = headers.get("content-transfer-encoding");
+ if (!(encoding == null || encoding.equals("7bit") || encoding.equals("8bit") || encoding.equals("binary") ||
+ encoding.equals("quoted-printable") || encoding.equals("base64"))) {
+ Log.warn(MIME.class, "unknown TransferEncoding \"" + encoding + "\"");
+ ctype = "application/octet-stream";