MyBB Community Forums

Full Version: [F] A bug, and a solution
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I've found and exterminated a small bug.

Someone noticed before that if you enter
\"
into any setting, it will create a syntax error in inc/settings.php. This person fixed the bug by adding a line of code. However, the same syntax error is produced if you enter
\\"
as well. In fact, this syntax error can be reproduced by entering any number of those \, and then a ". So, I decided that to resolve this once and for all, regular expressions would be worth using.

The MyBB guys may use this code anywhere they like.

EDIT: I updated the fix to use preg_replace() as opposed to ereg_replace().

If anyone has any trouble with this fix, post it here.
And why wouldn't $setting['value'] = str_replace("\"", "\\\"", $setting['value']); work in the first place? It's completely correct code
ask not why it doesn't work, but what code does work Wink

there is no spoon or something :p
The code does not work, Tikitiki. I explained how to reproduce the error--by entering \\", or \\\" as opposed to \".

EDIT: The old bug fix only stops \" from causing the error. That's what's wrong. \\", \\\" and any number of \ immediately before the " will still produce the error, so I wrote code that will resolve the issue for that pattern.
Ah yes indeed. I think I had too much root beer last night! I guess I toasted my birthday one too many times Big Grin


btw, I got an ipod nano silver 2 GB, and I have 185$ enough to buy vista pro! woo!
Tikitiki Wrote:Ah yes indeed. I think I had too much root beer last night! I guess I toasted my birthday one too many times Big Grin


btw, I got an ipod nano silver 2 GB, and I have 185$ enough to buy vista pro! woo!
Woot! That's cool. I wish I weren't so poor, so I could get something like that.

But yeah, is there a process for getting this patch official? I'd like to see a more functional MyBB.
I've replaced it in the svn code! Marking as fixed Smile
This bug has been fixed in the latest code.

Please note the latest code is not live on the site or for download. An update will be released which contains this fix.
That's cool. Someone got to it before I did, then, eh?
No, I used your patch

Also, are you sure $setting['value'] = ereg_replace("(\\\\*)\\\"","\\1\\1\\\"",$setting['value']); is right? Are you sure there is supposed to be two \\1 ?
Pages: 1 2