PDA

View Full Version : PHP Tag Slashes String Parsing Fix


Boofo
06-08-2003, 10:00 PM
PHP Tag Slashes String Parsing Fix
(By Boofo)

Thanks goes out to Firefly for not giving me an answer to my original request on how to fix this problem with the php tags. It forced me to figure it out for myself. ;)

What this hack does:
For anyone that uses php tags a lot, you'll know what this hack does. The phphighlite function does not handle slashes very well. And since only the php tags use that function, when you use the code tags there is no problem with the slashes being parsed right. This hack fixes that for any tags that use [ and ] (i.e. preg_replace statements). It has nothing to do with BBCode, but the way the php tags handle slashes (\). This hack keeps you from having to use \\\\[ to get a \[ in the php tags.

Files to modify: 1 (functions.php)
Templates to modify: None
Templates to add: None
Queries to run: None
Install time: 1 minute

Please click the install button if you find this hack useful.

Lethal
06-09-2003, 11:44 AM
cool thanks

Boofo
06-09-2003, 11:48 AM
You're very welcome. ;)

gmarik
06-09-2003, 12:16 PM
Still doen't get the point. I do use uch php code. What's the matter? Is there a way, to embed php in templates? Filburt's hack does not works on 2.3

Boofo
06-09-2003, 12:23 PM
If you try to put something like:

$message[message] = trim(preg_replace("~\[quote\](.*)\[/quote\]~si", "", $message[message]));

between php tags, you will have to change the \[ and \] to \\\[ and \\\] to make it parse right. With this hack, you no longer have to do that. The hack will automatically do this for you.

cirisme
06-09-2003, 12:40 PM
Has vb.org fixed this... let's find out! ;)

$message[message] = trim(preg_replace("~\[quote\](.*)\[/quote\]~si", "", $message[message]));

Boofo
06-09-2003, 12:49 PM
Chen fixed it here a while back. I decided to release my fix for it after I came across this problem on my site.

shovel
06-09-2003, 12:56 PM
So Bob, this will fix any further additions to tags (that use slashes) correct? You won't have to change any former function strings i.e. preg_replace()? If so, you have my install. :)

Boofo
06-09-2003, 01:01 PM
This will take care of it. The only thing you might have to do is go back and take out any extra slashes you added before to make the code look right. If you never added any extra slashes, then you are all set. ;)

shovel
06-09-2003, 01:21 PM
Only once, and it seems to be working fine now. Great fix Bob. :)

Boofo
06-09-2003, 01:46 PM
Glad you like it. ;) Enjoy!

Dean C
06-09-2003, 03:06 PM
Have you reported this as a bug at .com?

Boofo
06-09-2003, 05:54 PM
Nope, never bothered to. I figured Chen probably reported it a while ago when he fixed it here.

crocodile
06-16-2004, 06:43 AM
I tried.
but like
wsh.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\
this sentence still not work well, it shows out:
wsh.RegWrite "HKCUSoftwareMicrosoftInternet ExplorerMain
only when I type
wsh.RegWrite "HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\ It can show right

how can I fixed?

Boofo
06-16-2004, 06:48 AM
I tried.
but like
wsh.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\
this sentence still not work well, it shows out:
wsh.RegWrite "HKCUSoftwareMicrosoftInternet ExplorerMain

how can I fixed?
Try this:

wsh.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\"