web/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
--- a/web/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php	Thu Sep 16 15:45:36 2010 +0000
+++ b/web/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php	Mon Nov 19 18:26:13 2012 +0100
@@ -38,13 +38,13 @@
 			$matches = array();
 
 			// Skip this line.
-			if (strpos($dstr, "@") === 0)
+			if ($dstr[0] == "@")
 				continue;
 
-			preg_match("/\& ([^ ]+) .*/i", $dstr, $matches);
+			preg_match("/(\&|#) ([^ ]+) .*/i", $dstr, $matches);
 
-			if (!empty($matches[1]))
-				$returnData[] = utf8_encode(trim($matches[1]));
+			if (!empty($matches[2]))
+				$returnData[] = utf8_encode(trim($matches[2]));
 		}
 
 		return $returnData;
@@ -82,7 +82,7 @@
 			$matches = array();
 
 			// Skip this line.
-			if (strpos($dstr, "@") === 0)
+			if ($dstr[0] == "@")
 				continue;
 
 			preg_match("/\&[^:]+:(.*)/i", $dstr, $matches);
@@ -103,11 +103,15 @@
 	function _getCMD($lang) {
 		$this->_tmpfile = tempnam($this->_config['PSpellShell.tmp'], "tinyspell");
 
-		if(preg_match("#win#i", php_uname()))
-			return $this->_config['PSpellShell.aspell'] . " -a --lang=". escapeshellarg($lang) . " --encoding=utf-8 -H < " . $this->_tmpfile . " 2>&1";
+		$file = $this->_tmpfile;
+		$lang = preg_replace("/[^-_a-z]/", "", strtolower($lang));
+		$bin  = $this->_config['PSpellShell.aspell'];
 
-		return "cat ". $this->_tmpfile ." | " . $this->_config['PSpellShell.aspell'] . " -a --encoding=utf-8 -H --lang=". escapeshellarg($lang);
+		if (preg_match("#win#i", php_uname()))
+			return "$bin -a --lang=$lang --encoding=utf-8 -H < $file 2>&1";
+
+		return "cat $file | $bin -a --lang=$lang --encoding=utf-8 -H";
 	}
 }
 
-?>
\ No newline at end of file
+?>