rewriting tests after ctype/sm_ctype comparision and reading php manual more creafully.
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 7 Jun 2004 14:41:52 +0000 (14:41 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 7 Jun 2004 14:41:52 +0000 (14:41 +0000)
converted ereg to pcre. It would be better to include function_exist('ctype_space') test
in this function. P.S. reply code is broken if message includes double quotes.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7616 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/strings.php

index 238d04e616a034080dfe9f5c6fac170242c6b4df..1be033e9a1c4e22d25b1bffc0f85fa5a64d8c363 100644 (file)
@@ -78,10 +78,8 @@ function sqMakeNewLine (&$str, $citeLevel, &$column) {
  * Checks for spaces in strings - only used if PHP doesn't have native ctype support
  *
  * @author Tomas Kuliavas
- * According to Tomas:
- * You might be able to rewrite the function by adding short evaluation form
- * or using preg_match instead of ereg. It is possible that you must use
- * preg_match for binary safe comparison.
+ *
+ * You might be able to rewrite the function by adding short evaluation form.
  *
  * possible problems:
  *  - iso-2022-xx charsets  - hex 20 might be part of other symbol. I might
@@ -95,14 +93,14 @@ function sqMakeNewLine (&$str, $citeLevel, &$column) {
  * I don't see any charset/nbsp options in php ctype either.
  *
  * @param string $string tested string
- * @return bool true when space symbols are present in test string
+ * @return bool true when only whitespace symbols are present in test string
  */
 function sm_ctype_space($string) {
-   if ( ereg("[\11-\15]", $string) || ereg("[\40]", $string) ) {
-      return true;
-   } else {
-      return false;
-   }
+  if ( preg_match('/^[\x09-\x0D]|^\x20/', $string) || $string=='') {
+    return true;
+  } else {
+    return false;
+  }
 }
 
 /**