Skip to content

Commit

Permalink
explicitly set UTF-8 on all StringEntity. test with unescaped UTF-8
Browse files Browse the repository at this point in the history
git-svn-id: http://jcouchdb.googlecode.com/svn/trunk@229 b28efbb6-974e-0410-a7d0-456cb01d9dc4
  • Loading branch information
fforw@gmx.de committed Oct 28, 2009
1 parent a6be927 commit ed96fce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/org/jcouchdb/db/ServerImpl.java
Expand Up @@ -267,7 +267,7 @@ public Response put(String uri, String body)
HttpPut put = new HttpPut( serverURI + uri );
if (body != null) {
try {
StringEntity reqEntity = new StringEntity( body );
StringEntity reqEntity = new StringEntity( body , "UTF-8");
reqEntity.setContentType("application/json");
reqEntity.setContentEncoding( CHARSET );
put.setEntity( reqEntity );
Expand Down Expand Up @@ -332,7 +332,7 @@ public Response post(String uri, String body)

try
{
StringEntity reqEntity = new StringEntity(body);
StringEntity reqEntity = new StringEntity(body, "UTF-8");
reqEntity.setContentType("application/json");
reqEntity.setContentEncoding(CHARSET);
post.setEntity(reqEntity);
Expand Down
14 changes: 14 additions & 0 deletions test/org/jcouchdb/db/EncodingTestCase.java
Expand Up @@ -22,5 +22,19 @@ public void test()

}

@Test
public void testRealNonEscaped()
{
Database db = LocalDatabaseTestCase.createDatabaseForTest();
BaseDocument doc = new BaseDocument();
doc.setProperty("value", "Hello äöü♶");

db.createDocument(doc);

BaseDocument doc2 = db.getDocument(BaseDocument.class, doc.getId());
assertThat((String)doc2.getProperty("value"), is("Hello äöü♶"));

}


}

0 comments on commit ed96fce

Please sign in to comment.