From 2639dc67b147edfa3c491a2de05eeb3648141de5 Mon Sep 17 00:00:00 2001 From: hallgren Date: Tue, 23 Apr 2013 13:40:38 +0000 Subject: [PATCH] js/gfrobust.js: don't try to translate sentenses that are too long The C run-time responds badly to input that is too long, so we return an error message here instead. The limit is 200 URL-encoded characters. --- src/www/js/gfrobust.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/www/js/gfrobust.js b/src/www/js/gfrobust.js index fde72998b..9e0e0d929 100644 --- a/src/www/js/gfrobust.js +++ b/src/www/js/gfrobust.js @@ -14,8 +14,10 @@ gfrobust.call=function(querystring,cont) { // Translate a sentence to the given target language gfrobust.translate=function(source,to,cont) { - var enc=encodeURIComponent - gfrobust.call("?sentence="+enc(source)+"&to="+gfrobust.grammar+to,cont) + var encsrc=encodeURIComponent(source) + if(encsrc.length<200) // match limit in runtime/c/utils/pgf-server.c + gfrobust.call("?sentence="+encsrc+"&to="+gfrobust.grammar+to,cont) + else cont("[GF robust parser: sentence too long]") } // Get the url of a parse tree image (SVG)