From 8413fa1fc432aa2a13cbb4a296352bb9bad4d0cb Mon Sep 17 00:00:00 2001 From: John Bauer Date: Thu, 3 Mar 2022 11:29:38 -0800 Subject: [PATCH] Remove a double escaping of the patterns. It is unclear why that was needed, but it didn't work. The + and & would show up on the server side with an extra \ and the server would not properly handle them --- src/edu/stanford/nlp/pipeline/demo/corenlp-brat.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/edu/stanford/nlp/pipeline/demo/corenlp-brat.js b/src/edu/stanford/nlp/pipeline/demo/corenlp-brat.js index b3a4724bd7..1b76235c15 100644 --- a/src/edu/stanford/nlp/pipeline/demo/corenlp-brat.js +++ b/src/edu/stanford/nlp/pipeline/demo/corenlp-brat.js @@ -1220,10 +1220,12 @@ $(document).ready(function() { // Remove existing annotation $('#tokensregex').remove(); // Make ajax call + // Previously this would escape the + and & in pattern before the + // call to encodeURIComponent, but the server doesn't double + // unescape the incoming patterns, so that was not working $.ajax({ type: 'POST', - url: serverAddress + '/tokensregex?pattern=' + encodeURIComponent( - pattern.replace("&", "\\&").replace('+', '\\+')) + + url: serverAddress + '/tokensregex?pattern=' + encodeURIComponent(pattern) + '&properties=' + encodeURIComponent( '{"annotators": "' + annotators() + '", "date": "' + date() + '"}') + '&pipelineLanguage=' + encodeURIComponent($('#language').val()), @@ -1263,8 +1265,7 @@ $(document).ready(function() { // Make ajax call $.ajax({ type: 'POST', - url: serverAddress + '/semgrex?pattern=' + encodeURIComponent( - pattern.replace("&", "\\&").replace('+', '\\+')) + + url: serverAddress + '/semgrex?pattern=' + encodeURIComponent(pattern) + '&properties=' + encodeURIComponent( '{"annotators": "' + requiredAnnotators.join(',') + '", "date": "' + date() + '"}') + '&pipelineLanguage=' + encodeURIComponent($('#language').val()), @@ -1303,8 +1304,7 @@ $(document).ready(function() { // Make ajax call $.ajax({ type: 'POST', - url: serverAddress + '/tregex?pattern=' + encodeURIComponent( - pattern.replace("&", "\\&").replace('+', '\\+')) + + url: serverAddress + '/tregex?pattern=' + encodeURIComponent(pattern) + '&properties=' + encodeURIComponent( '{"annotators": "' + requiredAnnotators.join(',') + '", "date": "' + date() + '"}') + '&pipelineLanguage=' + encodeURIComponent($('#language').val()),