From d150a8ea75eab63c8af0f4cbfd360e174d8d703a Mon Sep 17 00:00:00 2001 From: Robert Kowalski Date: Sat, 25 Oct 2014 15:26:11 +0200 Subject: [PATCH] Add integration-test for newlines in location header COUCHDB-708 --- share/www/script/test/http.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/share/www/script/test/http.js b/share/www/script/test/http.js index 5f46af5296b..fb8672fafb2 100644 --- a/share/www/script/test/http.js +++ b/share/www/script/test/http.js @@ -25,7 +25,7 @@ couchTests.http = function(debug) { var xhr = CouchDB.request("PUT", "/test_suite_db/test", {body: "{}"}); var host = CouchDB.host; - TEquals(CouchDB.protocol + host + "/test_suite_db/test", + TEquals(CouchDB.protocol + host + "/test_suite_db/test", xhr.getResponseHeader("Location"), "should include ip address"); @@ -51,4 +51,29 @@ couchTests.http = function(debug) { xhr.getResponseHeader("Location"), "should include X-Host"); }); + + // COUCHDB-708: newlines document names + xhr = CouchDB.request("PUT", "/test_suite_db/docid%0A/attachment.txt", { + headers: {"Content-Type": "text/plain;charset=utf-8"}, + body: "" + }); + TEquals(CouchDB.protocol + host + "/test_suite_db/docid%0A/attachment.txt", + xhr.getResponseHeader("Location"), + "should work with newlines in document names for attachments"); + + xhr = CouchDB.request("PUT", "/test_suite_db/docidtest%0A", { + body: JSON.stringify({"foo": "bar"}), + headers: {"Content-Type": "application/json"} + }); + TEquals(CouchDB.protocol + host + "/test_suite_db/docidtest%0A", + xhr.getResponseHeader("Location"), + "should work with newlines in document names"); + + xhr = CouchDB.request("POST", "/test_suite_db/", { + body: JSON.stringify({"_id": "docidtestpost%0A"}), + headers: {"Content-Type": "application/json"} + }); + TEquals(CouchDB.protocol + host + "/test_suite_db/docidtestpost%250A", + xhr.getResponseHeader("Location"), + "should work with newlines in document names"); }