Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseResponse in fMailbox.php dies when the mail subject includes {123456} #208

Open
cqix opened this issue May 6, 2014 · 3 comments
Open

Comments

@cqix
Copy link

cqix commented May 6, 2014

Anyone an idea when this is necessary (parseResponse)?

    if (preg_match('#\{(\d+)\}#', $text, $match)) {
        $regex = '\{' . $match[1] . '\}\r\n.{' . ($match[1]) . '}|' . $regex;
    }

We cannot get a response which actually needs it but it finds e.g. {123456} within the mail subject and then dies with:
"preg_match_all(): Compilation failed: number too big in {} quantifier at offset 23"

@NeoVance
Copy link

It looks like the limit should be 65535, which makes sense because
that is the unsigned word boundry. You are parsing the WHOLE email text or ALL of the headers maybe?

I would make sure that you are sending only the subject line into the preg_match.

if you inisist on parsing the full email over a 65536 limit use strlen with the preg_match

if (strlen($str) <= 65536 && preg_match('/[A-Za-z0-9]+/', $str)) {

OR

if(strlen($text)>65536){
// too big
}

It is possible that the preg_match is attempting to parse the string into a variable type that can not hold it in the C code, in which case it would be a bug in the PHP command itself.

@karthickkumarganesh
Copy link

{123456} is literal which would be included when we have double quotes in Email subject and number corresponds to the character in Email subject
please check my issue : #192

@karthickkumarganesh
Copy link

i had solved this issue by doing some pattern replace and successfully resolved and fetch all Email ,
below are my code which help me achive this

please add this code to fMailbox.php after the line

$output = array();
line no nearly 1117

        $response = $this -> write('FETCH ' . $messages . ' (UID INTERNALDATE RFC822.SIZE ENVELOPE)');
        $hintter = implode(' ', $response);
        $pattern = '(\{[0-9]+\})';

        if (preg_match($pattern, $hintter, $match)) {

            $responses = preg_replace($pattern, '', $response);
            $responsesnew = array();
            $i = 0;
            $j = 0;
            foreach ($responses as $reps) {

                if (substr(trim($reps), 0, 1) != '*') {
                    $responsesnew[$i] = $responses[$j - 1] . $reps;
                    $i++;
                }

                $j++;

            }
        } else {
            $responsesnew = $response;
        }

and change the foreach parameters to
foreach ($responsesnew as $line)
from
foreach ($responsesnew as $line)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants