Log in

View Full Version : custom bbcode with ' or " in param


matkus
10-22-2008, 08:23 PM
Hello.

I have some problem. I want to create custom bbcode, that will link to something. Lets say user types
something
and it is converted to
<a href="http://example.com/?param=something">something</a>
Everything works fine if i simply add custom bb code, but when {param} have ' or ", because it closes href in link and it does not work anymore as expected. Is there any way to fix this without modding? Or if it need mod, can anyone give me small example or link to some mod, that i could use as example to create my own?

Marco van Herwaarden
10-23-2008, 09:24 AM
What are the values you entered when creating this bb-code?

matkus
10-23-2008, 01:52 PM
here's the exactly replacement i have for my bbcode
<a href="http://tibiaspy.com/index2.php?p=item&amp;itemname={param}" onmouseover="ajax_showTooltip('ajax_item.php?itemname={param} ',this);return false" onmouseout="ajax_hideTooltip()">{param}</a>
Everytjing works fine until I use ' or " as {param}, because it closes href or onmouseover tags.
thise ajax_xxxx functions are JS scripts i've found somewhere.

Can i in easy way replace ' and " to something else? it can be anyrhing, i'll parse it on my script as needed.

Marco van Herwaarden
10-23-2008, 03:04 PM
Try escaping them with a \.

matkus
10-23-2008, 04:28 PM
Sure, but i can't tell my users to escape parameters. Some people will not understand it or simply will not remember about it, and 95% will not read my instruction :P. I have to do this while converting bbcode to link, and i don't know how to do it.

Marco van Herwaarden
10-24-2008, 08:51 AM
You should escape the replacement text, not ask your users to escape strings.

matkus
10-24-2008, 09:32 AM
i know that, and i'm asking from first post how to do it.
I'm not vB guru, i don't know how to make vB mods, and also i don't know Javascript, so I can't make script to do this. I know PHP, but i can't use PHP in BBCode replacement, or at least i don't know how to do this.

Marco van Herwaarden
10-28-2008, 02:04 PM
Try changing your replacement code to:


<a href=\"http://tibiaspy.com/index2.php?p=item&amp;itemname={param}\" onmouseover=\"ajax_showTooltip(\'ajax_item.php?itemname={param} \',this);return false\" onmouseout=\"ajax_hideTooltip()\">{param}</a>

matkus
10-28-2008, 03:40 PM
I've copied Your code, but now forum does not convert it at all, like it didn't know that bbcode.
And when I use my bbcode, as Ravager's Axe it is converted to
<a href="http://tibiaspy.com/index2.php?p=item&amp;itemname=Ravager%27s%20Axe" onmouseover="ajax_showTooltip('ajax_item.php?itemname=Ravager's Axe ',this);return false" onmouseout="ajax_hideTooltip()">Ravager's Axe</a>as you can see, ' inside ajax_showTooltip closes parameter of that function, and so function does not work correctly.

Marco van Herwaarden
10-30-2008, 08:47 AM
Please post a screen shot of this BB-Code setting page.

matkus
11-03-2008, 10:49 AM
sure.
http://tibiaspy.com/temp/screen.jpg
Here's with Your code.
It's converted, like there was no bbcode at all.
And ofcourse i tried to disable all plugins, but, as i expected, that does not change anything.
With code i've posted somewhere above this BB code works fine, but, as i said, there is problem with apostroph in {param} closing parameter of JS function.