tags:

views:

112

answers:

5

This: <!---->

This little S.O.B, right there.

7 characters of evil, forcing IE to render all pages with it at the top like this in quirks mode:

<!----><!DOCTYPE html>
<html lang="en">
    <head>
     <meta charset="UTF-8">

If it's not evil I don't know what is because it certainly isn't in themes\default\overall.php, because the first few lines of that are:

<!DOCTYPE html>
<html lang="en">
    <head>
     <meta charset="UTF-8">
     <?php $this->outputHead(); ?>
    </head>

I certainly don't see any issues in my actual outputting code:

function build()
{
 if ($this->disabled)
 {
  return $this->content;
 }
 else
 {
  global $footer;
  ob_start();
  $location = $this->location;
  include($this->location['theme_nr'].'/overall.php');
  return ob_get_clean();
 }
}

function outputAll()
{
 // stop capturing everything
 $this->content = ob_get_clean();

 // build the page
 echo $this->build();
}

I just don't get it! How on earth could these horrendous 7 characters there get into my code?

I can just imagine that > bit at the end turning into a smile, and the thing is laughing at me.

Laughing like the S.O.B. it is, making me hate it and IE evermore.

It haunts my dreams, it kills my cats, I don't know what it's going to do next but it's going to kill something.

Why?!?!

EDIT: fyi it appears in all browsers

+1  A: 

I looked into the git repo you posted and it is not contained within. You could try a diff from the copy on github to your current copy as the change is in the changes you made.


If you are using an IDE do a global file search for the string of characters. These kinda of "bugs" can be troublesome.

MitMaro
I'm using Notepad++... I don't think it has such a feature as it's pretty much just an extended Notepad as the name implies.
a2h
Notepad++ has no trouble searching for <!---->
pavium
I've tried searching manually for <!----> in a couple of files before giving up.As for the git repo, it's up to date.
a2h
Notepad++ has the option of searching all open tabs (an option at the bottom of a normal CTRL+F search), so you can open a whole bunch of tabs and do one search through all of them.
Zurahn
Well. Nothing on my side. This is going to be nasty...
a2h
You should try searching <!-- instead of the whole thing. I suspect it's dumping out <!--[some blank variable]-->, so the search wouldn't pick it up.
Zurahn
Time to switch. I'd recommend NetBeans with PHP module - works great.
Ondra Žižka
Nice catch Zurahn.
MitMaro
A: 

Seems like a situation where grep would be handy, if you can use it either through cygwin or directly in Linux. A quick example of just finding files with that HTML comment

grep -R "<\!---->" ./*

That should narrow the search.

Zurahn
Unfortunately I use Windows. As for Cygwin, well, the last time I tried to install it I stared at the download size and gave up. That was one or two years ago.
a2h
Aw well, thought something like that might be the case, but figured I'd throw it out there anyway.
Zurahn
Possibly not the simplest way, but you can get an account at http://silenceisdefeat.com/ (free Unix), upload your file using SFTP with something like Filezilla, then connect to it with Putty and run the command given above :D
Brendan Long
get cygwin. It's about 10 youtube vids in size.
Shawn Leslie
+2  A: 

I found the culprit.

Somehow, my isexistinguser() function and how it uses a cheap method to hide a MySQL error is only causing issues in my branch ribbonpageedit and not master, even though the function and where it is called from hasn't changed between the two branches.

Looks like I should go and strangle it now actually ask how I should deal with the MySQL error.

For those interested, the function in question:

function isexistinguser($uname,$pwd)
{
    global $location;

    $uname = mysql_real_escape_string($uname);

    $result = mysql_query("SELECT * FROM users WHERE user_username = '$uname'");

    /* description of $hit:
     *  -1 more than one match of the username for some reason
     *   0 no match for both username/password
     *   1 match for both username/password
     *   2 match for username, no match for password
     *   3 match for password, no match for username
    */

    $hit = 0;
    $rowcounted = false;
    $salt = '';

    echo '<!--'; // cheap fix for mysql error - FIND A BETTER WAY!

    while($row = mysql_fetch_array($result))
    {  
     $salt = $row['user_password_salt'];

     if (!$rowcounted && $hit != -1)
     {
      if ($uname == $row['user_username'])
      {
       $hit = 2;
      }
      if (user_pass_generate($row['user_password_salt'],$pwd) == $row['user_password'])
      {
       if ($hit == 2)
        $hit = 1;
       else
        $hit = 3;
      }
     }
     else
     {
      $hit = -1;
     }

     // this is for debugging the mysql user handling system
     //echo $hit.'<br /><br />'.user_pass_generate($row['user_password_salt'],$pwd).'<br /><br />';
    }

    echo '-->'; // cheap fix for mysql error - FIND A BETTER WAY!

    return array($hit,$salt);
}
a2h
That's really funny. I also like how isexistinguser looks like extinguisher and...you probably already know what $hit looks like. :)
Kevin
`$hit` looks like what..?
a2h
The physically appearance of $hit can vary depending on the $hit factory itself, or the parameters passed to the $hit factory prior to the job execution to create the $hit. Most commonly, it usually has a constant Color member of Color.SaddleBrown and has a bad code smell.
snicker
A: 

About your error handling. The first way of dealing with it is to define and use your own handlers instead of php default ones with set_error_handler.

As a simple fix, modify this line : $result = mysql_query("SELECT * FROM users WHERE user_username = '$uname'"); with something like that :

$result = mysql_query("SELECT * FROM users WHERE user_username = '$uname'");
if(!$result || !is_resource($result){
  return array(0, '');
}

To end this, I recommend you check PDO to use databases.

Arkh
Actually, I found the error's derived from something completely different, and I'm now trying to figure out what's causing *that* issue - http://stackoverflow.com/questions/1845587/how-come-my-php-sessions-arent-carrying-across
a2h
A: 

I would have looked for the 'evil' string:

grep -R '\-\->' /your/folder

pcp