Skip to content

Commit 20fe1e9

Browse files
committed
If decoding fails, fall back to using the original text. Addresses #1226
1 parent aac9202 commit 20fe1e9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,11 @@ private Annotation getDocument(Properties props, HttpExchange httpExchange) thro
327327

328328
String text = IOUtils.slurpReader(IOUtils.encodedInputStreamReader(httpExchange.getRequestBody(), encoding));
329329
if (contentType.equals(URL_ENCODED)) {
330-
text = URLDecoder.decode(text, encoding);
330+
try {
331+
text = URLDecoder.decode(text, encoding);
332+
} catch (IllegalArgumentException e) {
333+
// ignore decoding errors so that libraries which don't specify a content type might not fail
334+
}
331335
}
332336
// We use to trim. But now we don't. It seems like doing that is illegitimate. text = text.trim();
333337

0 commit comments

Comments
 (0)