Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] A bug, and a solution
#1
I've found and exterminated a small bug.

Someone noticed before that if you enter
Code:
\"
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
Code:
\\"
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.


Attached Files
.txt   mybb_bug_patch_2.0.txt (Size: 991 bytes / Downloads: 222)
--Macai

Join the Dragon's Eye Guild! http://dragonseyeguild.net
#2
And why wouldn't $setting['value'] = str_replace("\"", "\\\"", $setting['value']); work in the first place? It's completely correct code
#3
ask not why it doesn't work, but what code does work Wink

there is no spoon or something :p
#4
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.
--Macai

Join the Dragon's Eye Guild! http://dragonseyeguild.net
#5
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!
#6
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.
--Macai

Join the Dragon's Eye Guild! http://dragonseyeguild.net
#7
I've replaced it in the svn code! Marking as fixed Smile
#8
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.
#9
That's cool. Someone got to it before I did, then, eh?
--Macai

Join the Dragon's Eye Guild! http://dragonseyeguild.net
#10
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 ?


Forum Jump:


Users browsing this thread: 1 Guest(s)