Regex tester: "Match is not a valid associative array"

40Dialogues's Avatar

40Dialogues

16 Nov, 2014 06:51 PM

  1. Open inc/test.inc on Chromium.
  2. Open [Regex tester] tab.
  3. Change nothing. Just click [TEST].
    -> Error "Match is not a valid associative array"

In Chromium debugger, Form Data is shown as follows:

(...snip...)&m=%7B%0A++%22Date%22%3A%5B%0A++++3%2C%0A++++%22%5C%2F%22%2C%0A++++2%2C%0A++++%22%5C%2F%22%2C%0A++++1%2C%0A++++%22+%22%2C%0A++++4%2C%0A++++%22%3A%22%2C%0A++++5%2C%0A++++%22%3A%22%2C%0A++++6%0A++%5D%2C%0A++%22Error%22%3A7%0A%7D&t=(...snip...)

Doing error_log( $_POST['m'] ) at line 90 of test.php emits this:

[16-Nov-2014 18:37:10] {
  \"Date\":[
    3,
    \"\\/\",
    2,
    \"\\/\",
    1,
    \" \",
    4,
    \":\",
    5,
    \":\",
    6
  ],
  \"Error\":7
}

For the record, magic_quotes_gpc is ON on my server.

  1. 1 Posted by 40Dialogues on 16 Nov, 2014 07:03 PM

    40Dialogues's Avatar

    Never mind. I realized I was allowed to set .htaccess as follows, and the error gone away.

    php_flag magic_quotes_gpc Off
    
  2. Support Staff 2 Posted by potsky on 16 Nov, 2014 07:10 PM

    potsky's Avatar

    I have thought about adding this setting in a .htaccess file but it will not work for users on nginx and IIS with PHP 5.2 for example.

    Can you try to remove the .htaccess file and add these lines at the end of global.inc.php for example please ? (before ?>of course)

    if (get_magic_quotes_gpc()) {
        $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
        while (list($key, $val) = each($process)) {
            foreach ($val as $k => $v) {
                unset($process[$key][$k]);
                if (is_array($v)) {
                    $process[$key][stripslashes($k)] = $v;
                    $process[] = &$process[$key][stripslashes($k)];
                } else {
                    $process[$key][stripslashes($k)] = stripslashes($v);
                }
            }
        }
        unset($process);
    }
    
  3. 3 Posted by 40Dialogues on 16 Nov, 2014 07:31 PM

    40Dialogues's Avatar

    Removed .htaccess. Confirmed the error reappeared. Inserted your code into global.inc.php. Now the [TEST] button succeeds without the error.

    Thank you for taking time.

  4. Support Staff 4 Posted by potsky on 16 Nov, 2014 07:34 PM

    potsky's Avatar

    Nice !

    I will add this for the release tomorrow.

    Star Pimp My Log on Github if you like it !

  5. potsky closed this discussion on 16 Nov, 2014 07:34 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac