Skip to content

Commit

Permalink
If decoding fails, fall back to using the original text. Addresses #1226
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Dec 3, 2021
1 parent aac9202 commit 20fe1e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java
Expand Up @@ -327,7 +327,11 @@ private Annotation getDocument(Properties props, HttpExchange httpExchange) thro

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

Expand Down

0 comments on commit 20fe1e9

Please sign in to comment.