ID:               30971
 User updated by:  jed at jed dot bz
 Reported By:      jed at jed dot bz
-Status:           Feedback
+Status:           Open
 Bug Type:         Unknown/Other Function
 Operating System: *
-PHP Version:      Irrelevant
+PHP Version:      4CVS, 5CVS
 New Comment:

This has been there since at least early 2003. And it's reproducable in
both CVSes.


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

[2004-12-03 09:20:48] [EMAIL PROTECTED]

Please fill in your PHP version.

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

[2004-12-03 00:56:32] jed at jed dot bz

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