summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-04-23 13:40:38 +0000
committerhallgren <hallgren@chalmers.se>2013-04-23 13:40:38 +0000
commit2639dc67b147edfa3c491a2de05eeb3648141de5 (patch)
tree601255ef30b3bc2321120df4dcf577c5759df69f
parentba1bdaa3dcfb3fba1332ba1aeb6cdaf14c459485 (diff)
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.
-rw-r--r--src/www/js/gfrobust.js6
1 files 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)