From 7fface125e7db1e7ab47bdfbda5306fa16ea2486 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 25 Apr 2014 03:56:22 -0400
Subject: [PATCH] Fix error when spell-checking an empty text (#1489831)
---
CHANGELOG | 1 +
program/lib/Roundcube/rcube_spellcheck_googie.php | 4 ++++
program/js/googiespell.js | 1 +
program/steps/utils/spell_html.inc | 2 +-
program/steps/utils/spell.inc | 3 +++
5 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7144f35..91d065b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
- Fix redundant alert message on over-size uploads (#1489817)
- Fix next message display after removing a message (#1489800)
- Fix missing Mail-Followup-To header in sent mail (#1489829)
+- Fix error when spell-checking an empty text (#1489831)
RELEASE 1.0.0
-------------
diff --git a/program/js/googiespell.js b/program/js/googiespell.js
index c33c568..de58b7e 100644
--- a/program/js/googiespell.js
+++ b/program/js/googiespell.js
@@ -289,6 +289,7 @@
this.cnt_errors_fixed = 0;
this.cnt_errors = 0;
this.setStateChanged('checking_spell');
+ this.orginal_text = '';
if (!no_indicator && this.main_controller)
this.appendIndicator(this.spell_span);
diff --git a/program/lib/Roundcube/rcube_spellcheck_googie.php b/program/lib/Roundcube/rcube_spellcheck_googie.php
index 3777942..f9e450f 100644
--- a/program/lib/Roundcube/rcube_spellcheck_googie.php
+++ b/program/lib/Roundcube/rcube_spellcheck_googie.php
@@ -56,6 +56,10 @@
{
$this->content = $text;
+ if (empty($text)) {
+ return $this->matches = array();
+ }
+
// spell check uri is configured
$url = rcube::get_instance()->config->get('spellcheck_uri');
diff --git a/program/steps/utils/spell.inc b/program/steps/utils/spell.inc
index c8807e3..696fa60 100644
--- a/program/steps/utils/spell.inc
+++ b/program/steps/utils/spell.inc
@@ -37,6 +37,9 @@
$spellchecker->add_word($data);
$result = '<?xml version="1.0" encoding="'.RCUBE_CHARSET.'"?><learnwordresult></learnwordresult>';
}
+else if (empty($data)) {
+ $result = '<?xml version="1.0" encoding="'.RCUBE_CHARSET.'"?><spellresult charschecked="0"></spellresult>';
+}
else {
$spellchecker->check($data);
$result = $spellchecker->get_xml();
diff --git a/program/steps/utils/spell_html.inc b/program/steps/utils/spell_html.inc
index 27b14ac..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);
--
Gitblit v1.9.1