ID:               30971
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Verified
 Bug Type:         Strings related
 Operating System: *
-PHP Version:      4CVS, 5CVS
+PHP Version:      5.0.3
 New Comment:

Okay, getting ahead of myself. There's been a radical change from 5.0.2
to 5.0.3, and it appears to have been partially repaired, but
highlighting is still botched.

Screenshots:

   Bad: http://labs.jed.bz/renewed_bad.png
  Good: http://labs.jed.bz/renewed_good.png

Hopefully this change will give someone more experienced with the
parser a hook into this odd behavior? This definitely changed between
5.0.2 and 5.0.3, but the bug in various forms still exists in both 4
and 5.


Previous Comments:
------------------------------------------------------------------------

[2005-01-04 05:09:17] [EMAIL PROTECTED]

This is still my bug, and hey, I have CVS now, so I can verify it too.
Parsers really scare me so I'm not sure where to look to fix this, but
hopefully verifying it will renew interest in this? This seems like a
core parser problem.

------------------------------------------------------------------------

[2004-12-14 22:54:30] jed at jed dot bz

Eh? Gave up already?

------------------------------------------------------------------------

[2004-12-03 00:56:32] [EMAIL PROTECTED]

Description:
------------
Bug 25725 was marked bogus due to a bad example. I am reopening it here
because this is a particularly annoying bug that needs to be fixed,
regardless of 'this is not an issue' sentiment within the PHP
community.

When the highlight_string() engine encounters ANY \ character, even one
prefixing an escape like \n (which are LEGAL, as some astute Quick Fix
posters have ignored), the parser interjects warnings into
highlight_string()'s output. The catch? This only happens randomly.

We rely on highlight_string() for our IRC pastebin, and I am sure this
function is used a lot elsewhere. I have submitted another entry to our
pastebin and was quite disappointed to see the bug's problem at once:

     http://labs.jed.bz/phpbug3.png
  Screenshot taken from
     http://dalphp.shoggoth.net/pastebin_view.php?533

I have highlighted the problem for the QA reviewers with itchy Quick
Fix fingers. Notice the 'n' sitting on a line all by itself? That's the
back end of a \n sequence, and the PHP parser is erring on the \ itself.
It's as if the tokenizer, when used under highlight_string(), isn't
glomming \ onto its following character.

It is also only doing it on some newlines. As you can see, the newlines
next to '019' (the bottom of the highlight) are parsed fine! As you can
also see, the colors in the rest of the code, even on keywords that
should be highlighted green like 'static' and 'function', are all
messed up.

This isn't the first time we've run into this. I've taken screenshots
to append to Bug 25725, but they were ignored as well. I rewind and
replay them here for community benefit.

   CORRECT: http://labs.jed.bz/phpbug2.png
       NOT: http://labs.jed.bz/phpbug.png
Source URL: http://dalphp.shoggoth.net/pastebin_view.php?356

Nothing changed on the server between these two requests. I just
refreshed until the output changed. And these are legal newlines. The
example on Bug 25725 brought the itchy Quick Fix fingers out, but the
submitter presented a valid point, which I reiterate here.

Highlighted fine:

    $x = 0
    $y = 1
    $z = 2

Not highlighted fine:

    $x = 0;
    \;
    $z = 2;

And as I've demonstrated, this isn't highlighted fine either:

    printf("\n");

The randomness of this problem suggests a leak or black magic within
PHP itself, and I have a gut feeling this is a little more problematic
than it appears at first hand. The reproduce code below is what is
supposed to be highlighted in phpbug3.png.

Note: Do not flood dalphp.shoggoth.net with refresh requests, trust my
screenshots.

Reproduce code:
---------------
<?php
/**
 * The beefiest exceptioner evar.
 */

public static function ErrorHandler(Exception $e) {
    // FIXME //
    if(file_exists($e->getFile())) {
        $line = file($e->getFile());
        $line = trim($line[$e->getLine() - 1]);
    }
    else $line = "?";
    printf("\n\nSTOP. Uncaught exception \"%s\" in %s:%u\n" .
        "  >> %s\n" .
        "  Message: (%u) %s\n  Backtrace:\n", get_class($e),
$e->getFile(),
        $e->GetLine(), $line, $e->getCode(), $e->getMessage());
    $i = 0;
    foreach($e->getTrace() as $bt)
        printf("     (#%u) %s()\n", ++$i, $bt['class'] . $bt['type'] .
$bt['function'],
            $bt['file'], $bt['line']);
        
    printf("\n\n");
    exit(0xFE);
} 

Expected result:
----------------
http://labs.jed.bz/phpbug4.png

Actual result:
--------------
http://labs.jed.bz/phpbug3.png
(Sporadically)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30971&edit=1

Reply via email to