diff --git a/inc/aspell.php b/inc/aspell.php index 17ad4884abffff6637ee7afd59ec5d38e5fcee01..72d2f8b8697aa804b7677904cd99fe24ccbd3e15 100644 --- a/inc/aspell.php +++ b/inc/aspell.php @@ -72,6 +72,7 @@ class Aspell{ var $jargon = null; var $encoding = 'iso8859-1'; var $mode = PSPELL_NORMAL; + var $version = 0; var $args=''; @@ -195,9 +196,9 @@ class Aspell{ // versions of Aspell. $tmp = array(); preg_match('/^\@.*Aspell (\d+)\.(\d+).(\d+)/',$out,$tmp); - $version = $tmp[1]*1000 + $tmp[2]*10 + $tmp[3]; + $this->version = $tmp[1]*100 + $tmp[2]*10 + $tmp[3]; - if ($version <= 603) // version 0.60.3 + if ($this->version <= 603) // version 0.60.3 $r = $terse ? "\n*\n\$1" : "\n\$1"; // replacement for broken Aspell else $r = $terse ? "\n*\n" : "\n"; // replacement for good Aspell diff --git a/lib/exe/spellcheck.php b/lib/exe/spellcheck.php index 0a3a8403bd30181fa69bc073cdb4f9a254ff4985..67448673cffbf28fe72aec7c953f9a2ebadee3a9 100644 --- a/lib/exe/spellcheck.php +++ b/lib/exe/spellcheck.php @@ -165,8 +165,14 @@ function spell_check() { } $misspell = true; - $len = utf8_strlen($word); - $data[$lcnt] = utf8_substr_replace($data[$lcnt],spell_formatword($word,$sug),$off, $len); + //aspell < 0.60 returns singlebyte offsets + if($spell->version >= 600){ + $len = utf8_strlen($word); + $data[$lcnt] = utf8_substr_replace($data[$lcnt],spell_formatword($word,$sug),$off, $len); + }else{ + $len = strlen($word); + $data[$lcnt] = substr_replace($data[$lcnt],spell_formatword($word,$sug),$off, $len); + } }//end of output parsing