Menu

#1 Javascript bug

closed-fixed
nobody
None
5
2003-07-25
2003-06-17
simoncpu
No

Hello there!

I'm writing this here to provide further details about that
bug I told earlier. The following code would produce a
valid Javascript code: :)

<a href="javajavascript:script\0:alert('simoncpu');">A
Bug!</a>

Inserting this at the beginning of the kses_bad_js()
function should do the trick:

$string = preg_replace('/\0*', '', $string);

BTW, does PHP automatically append a NULL at the end
of the string? Although this code works fine on my
system, I'm not sure if this is compatible with others.
We may need to manually terminate it.

Lastly, the filter.php example doesn't work on my
system, because $SCRIPT_NAME doesn't work. I'm using
a PHP Version 4.2.3, running on Windows XP, IIS 5.1,
BTW.

[ simon.cpu ]

Discussion

  • Ulf Harnhammar

    Ulf Harnhammar - 2003-06-19

    Logged In: YES
    user_id=573278

    Sure, I'll test your preg_replace() thing on my machine.

    I think PHP treats NULLs more like Perl than C, so you can
    have a NULL in the middle of a string and they're not
    terminated by them.

    SCRIPT_NAME is weird. Try $SERVER['SCRIPT_NAME'] and
    $SERVER['PHP_SELF']. We could write filter.php instead, but
    then it wouldn't work if someone would rename the script :)

    I'm using Linux.

    // metaur

     
  • Ulf Harnhammar

    Ulf Harnhammar - 2003-07-25

    Logged In: YES
    user_id=573278

    Both the NULL bug and the $SCRIPT_NAME bug is fixed in
    0.2.0.

     
  • Ulf Harnhammar

    Ulf Harnhammar - 2003-07-25
    • status: open --> closed-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.