From a54cff4c569f74f7ec1b2ab8379b7ad1820a8af9 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 25 Apr 2014 03:55:00 -0400
Subject: [PATCH] Fix error when spell-checking an empty text (#1489831)

---
 program/steps/utils/spell_html.inc |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/program/steps/utils/spell_html.inc b/program/steps/utils/spell_html.inc
index 861e4ba..5935dc1 100644
--- a/program/steps/utils/spell_html.inc
+++ b/program/steps/utils/spell_html.inc
@@ -35,7 +35,7 @@
 $spellchecker = new rcube_spellchecker($lang);
 
 if ($request['method'] == 'checkWords') {
-    $result['result'] = $spellchecker->get_words($data);
+    $result['result'] = empty($data) ? array() : $spellchecker->get_words($data);
 }
 else if ($request['method'] == 'getSuggestions') {
     $result['result'] = $spellchecker->get_suggestions($data);
@@ -46,12 +46,17 @@
 }
 
 if ($error = $spellchecker->error()) {
+    rcube::raise_error(array('code' => 500, 'type' => 'php',
+        'file' => __FILE__, 'line' => __LINE__,
+        'message' => sprintf("Spell check engine error: " . $error)),
+        true, false);
+
     echo '{"error":{"errstr":"' . addslashes($error) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}';
     exit;
 }
 
 // send output
-header("Content-Type: text/xml; charset=".RCMAIL_CHARSET);
+header("Content-Type: text/xml; charset=".RCUBE_CHARSET);
 echo json_encode($result);
 exit;
 

--
Gitblit v1.9.1