Skip to content
Permalink
Browse files

Attempt to clean up some issues wrt content-type in p:data; maybe fix…

… bug #154?
  • Loading branch information
ndw committed Aug 15, 2014
1 parent d5ca853 commit b3f26519e97f710b69156101f40c1f0885abd87c
Showing with 19 additions and 19 deletions.
  1. +19 −19 src/com/xmlcalabash/io/ReadableData.java
@@ -125,7 +125,18 @@ private void read(String userContentType, URI dataURI,
throws IOException {
this.serverContentType = serverContentType;

String userCharset = parseCharset(contentType);
contentType = serverContentType;

// If the input is - or a file: URI, assume the user provided content type
// and charset are correct.
if ((uri != null) && ("-".equals(uri) || "file".equals(dataURI.getScheme()))) {
if (userContentType != null) {
contentType = userContentType;
}
}

String charset = parseCharset(contentType);

TreeWriter tree = new TreeWriter(runtime);
tree.startDocument(dataURI);
if (contentType != null && "content/unknown".equals(serverContentType)) {
@@ -143,17 +154,6 @@ private void read(String userContentType, URI dataURI,
serverContentType = serverBaseContentType + "; charset=\"" + serverCharset + "\"";
}

// If the user specified a charset and the server did not and it's a file: URI,
// assume the user knows best.
// FIXME: provide some way to override this!!!

String charset = serverCharset;
if ((uri != null) && ("-".equals(uri) || "file".equals(dataURI.getScheme()))
&& serverCharset == null
&& serverBaseContentType.equals(userContentType)) {
charset = userCharset;
}

if (runtime.transparentJSON() && HttpUtils.jsonContentType(contentType)) {
if (charset == null) {
// FIXME: Is this right? I think it is...
@@ -166,27 +166,27 @@ private void read(String userContentType, URI dataURI,
} else {
tree.addStartElement(wrapper);
if (XProcConstants.c_data.equals(wrapper)) {
if ("content/unknown".equals(serverContentType)) {
if ("content/unknown".equals(contentType)) {
tree.addAttribute(_contentType, "application/octet-stream");
} else {
tree.addAttribute(_contentType, serverContentType);
tree.addAttribute(_contentType, contentType);
}
if (!isText(serverContentType, charset)) {
if (!isText(contentType, charset)) {
tree.addAttribute(_encoding, "base64");
}
} else {
if ("content/unknown".equals(serverContentType)) {
if ("content/unknown".equals(contentType)) {
tree.addAttribute(c_contentType, "application/octet-stream");
} else {
tree.addAttribute(c_contentType, serverContentType);
tree.addAttribute(c_contentType, contentType);
}
if (!isText(serverContentType, charset)) {
if (!isText(contentType, charset)) {
tree.addAttribute(c_encoding, "base64");
}
}
tree.startContent();

if (isText(serverContentType, charset)) {
if (isText(contentType, charset)) {
BufferedReader bufread;
if (charset == null) {
// FIXME: Is this right? I think it is...

0 comments on commit b3f2651

Please sign in to comment.
You can’t perform that action at this time.