Skip to content

Commit 1f2fbe1

Browse files
committed
Fix to allow uris with different characters.
1 parent f920aab commit 1f2fbe1

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,8 +3569,13 @@ public <R extends AbstractReadHandle> R postBulkDocuments(
35693569
mimeType = defaultFormat.getDefaultMimetype();
35703570
}
35713571
headers.add(HEADER_CONTENT_TYPE, mimeType);
3572-
String disposition = DISPOSITION_TYPE_ATTACHMENT + "; " +
3573-
DISPOSITION_PARAM_FILENAME + "=" + escapeContentDispositionFilename(write.getUri()) + contentDispositionTemporal;
3572+
String disposition = null;
3573+
try {
3574+
disposition = DISPOSITION_TYPE_ATTACHMENT + "; " +
3575+
DISPOSITION_PARAM_FILENAME + "*=UTF-8''" + URLEncoder.encode(write.getUri(), "UTF-8") + contentDispositionTemporal;
3576+
} catch (Exception ex) {
3577+
ex.printStackTrace();
3578+
}
35743579
headers.add(HEADER_CONTENT_DISPOSITION, disposition);
35753580
headerList.add(headers);
35763581
writeHandles.add(write.getContent());

marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/WriteBatcherTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,4 +1141,24 @@ public void testIssue793() {
11411141
moveMgr.startJob(batcher);
11421142
moveMgr.stopJob(batcher);
11431143
}
1144+
1145+
@Test
1146+
public void testUrisWithDifferentCharacters() {
1147+
GenericDocumentManager docMgr = client.newDocumentManager();
1148+
DocumentWriteSet writeSet = docMgr.newWriteSet();
1149+
StringHandle handle1 = new StringHandle("{hello:\"test1\"}");
1150+
StringHandle handle2 = new StringHandle("{hello:\"test2\"}");
1151+
1152+
writeSet.add("/CXXXX_Ü_9999.json", handle1);
1153+
writeSet.add("Ä_9999.json", handle2);
1154+
docMgr.write(writeSet);
1155+
1156+
DocumentPage documentsPage = docMgr.read("/CXXXX_Ü_9999.json","Ä_9999.json");
1157+
assertTrue("All the documents were not written.",documentsPage.size() == 2);
1158+
assertEquals("First document content not as expected.",handle1,documentsPage.next().getContent(handle1));
1159+
assertEquals("Second document content not as expected.",handle2,documentsPage.next().getContent(handle2));
1160+
1161+
client.newDocumentManager().delete("/CXXXX_Ü_9999.json");
1162+
client.newDocumentManager().delete("Ä_9999.json");
1163+
}
11441164
}

0 commit comments

Comments
 (0)