2 notices, \ needs literal
authoralex-brainstorm <alex-brainstorm@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 11 Jul 2003 09:53:35 +0000 (09:53 +0000)
committeralex-brainstorm <alex-brainstorm@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 11 Jul 2003 09:53:35 +0000 (09:53 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5261 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_asearch.php

index a4eeb6a5d0195f0cede9c4b31ed403cedf5cd566..b793eca677ec881cf7bcffb48d2ea8d8d3d353d0 100644 (file)
@@ -111,11 +111,18 @@ function s_debug_dump($var_name, $var_var, $compact = FALSE)
                s_dump($var_name, $var_var, $compact);
 }
 
+/*
+4.3 String:
+       A quoted string is a sequence of zero or more 7-bit characters,
+        excluding CR and LF, with double quote (<">) characters at each end.
+9. Formal Syntax:
+       quoted-specials = DQUOTE / "\"
+*/
 function sqimap_asearch_encode_string($what, $search_charset)
 {
        if (strtoupper($search_charset) == 'ISO-2022-JP')
                $what = mb_convert_encoding($what, 'JIS', 'auto');
-       if (strpos($what,'"') > -1)
+       if (ereg("[\"\\\r\n]", $what))
                return '{' . strlen($what) . "}\r\n" . $what;   /* 4.3 literal form */
        return '"' . $what . '"';       /* 4.3 quoted string form */
 }
@@ -123,16 +130,16 @@ function sqimap_asearch_encode_string($what, $search_charset)
 /*
  Parses a user date string into an rfc2060 date string (<day number>-<US month TLA>-<4 digit year>)
  Returns a preg_match-style array: [0]: fully formatted date, [1]: day, [2]: month, [3]: year
- Handles space, slash, dot and comma as separators (and dash of course ;=)
+ Handles space, slash, backslash, dot and comma as separators (and dash of course ;=)
 */
 function sqimap_asearch_parse_date($what)
 {
        global $imap_asearch_months;
 
        $what = trim($what);
-       $what = ereg_replace('[ :,:/:.]+', '-', $what);
+       $what = ereg_replace('[ /\\.,]+', '-', $what);
        if ($what) {
-               preg_match('/^([0-9]+)-([^\-]+)-([0-9]+)$/', $what, $what_parts);
+               preg_match('/^([0-9]+)-+([^\-]+)-+([0-9]+)$/', $what, $what_parts);
                if (count($what_parts) == 4) {
                        $what_month = strtolower(asearch_unhtmlentities($what_parts[2]));
 /*             if (!in_array($what_month, $imap_asearch_months)) {*/
@@ -159,6 +166,7 @@ function sqimap_asearch_build_criteria($opcode, $what, $search_charset)
 {
        global $imap_asearch_opcodes;
 
+       $criteria = '';
        switch ($imap_asearch_opcodes[$opcode]) {
                default:
                case 'anum':
@@ -179,7 +187,7 @@ function sqimap_asearch_build_criteria($opcode, $what, $search_charset)
                break;
                case 'adate':
                        $what_parts = sqimap_asearch_parse_date($what);
-                       if ($what_parts[0] != '')
+                       if (isset($what_parts[0]))
                                $criteria = $opcode . ' ' . $what_parts[0] . ' ';
                break;
                case 'akeyword':