Page 1 of 2

URL problem in BBCode

Posted: Sun Jun 03, 2007 9:44 am
by sikita
When I use URL in any custom bbcode a have this problem:

Example bbcode:

Code: Select all

[web]{URL}[/web]
<iframe src={URL} width="700" height="500"></iframe>
I didnt get correct iframe but this error and code:

Code: Select all

<iframe src=<!-- m --><a class="postlink" href="http://www.xxx.com">http://www.xxx.com</a><!-- m --> width="700" height="500"></iframe>
Where can I disable this: <!-- m --><a class="postlink" href="...."> ????

This happens always with any URL even using {TEXT}.

Any solution? Thankx

Re: URL problem in BBCode

Posted: Sun Jun 03, 2007 9:47 am
by karlsemple

Code: Select all

[iframe={URL} {NUMBER} {NUMBER1}][/iframe]

Code: Select all

<iframe src="{URL}" frameborder="0" scrolling="no" height="{NUMBER}" width="{NUMBER1}"></iframe>

Re: URL problem in BBCode

Posted: Sun Jun 03, 2007 12:49 pm
by sikita
The problem is not in iframe tag but in url parsing! Because it is changed to "<!-- m --><a class="postlink" href="...."

As you can see it is

Code: Select all

<iframe src=<!-- m --><a class="postlink" href="http://www.xxx.com">http://www.xxx.com</a><!-- m --> width="700" height="500"></iframe>
but it should be

Code: Select all

<iframe src=http://www.xxx.com width="700" height="500"></iframe>

Re: URL problem in BBCode

Posted: Sun Jun 03, 2007 1:05 pm
by karlsemple
sikita wrote:The problem is not in iframe tag but in url parsing! Because it is changed to "<!-- m --><a class="postlink" href="...."

As you can see it is

Code: Select all

<iframe src=<!-- m --><a class="postlink" href="http://www.xxx.com">http://www.xxx.com</a><!-- m --> width="700" height="500"></iframe>
but it should be

Code: Select all

<iframe src=http://www.xxx.com width="700" height="500"></iframe>

did you try my way?

Re: URL problem in BBCode

Posted: Sun Jun 03, 2007 1:27 pm
by sikita
Yes, it is working... why it is not working between tags? [iframe]www.xxx.com[/iframe] ?

Re: URL problem in BBCode

Posted: Sun Jun 03, 2007 1:34 pm
by karlsemple
sikita wrote:Yes, it is working... why it is not working between tags? [iframe]www.xxx.com[/iframe] ?

because that is not how you format iframe tags, not to mention doing it your way the link between the iframe tag is being passed through the make clickable functions which adds the bits you were on about to the text ready for submission to the database.

Re: URL problem in BBCode

Posted: Sun Jun 03, 2007 1:41 pm
by dark/Rain
Similar/the same: http://www.phpbb.com/bugs/phpbb3/ticket ... t_id=11893 ?

//Edit: I should refresh the page before posting :|
It's the same (and a bug IMO)...

Re: URL problem in BBCode

Posted: Tue Jun 12, 2007 12:57 pm
by Youvan
I have the problem, that everytime, when I use the IFrame-BBCode (self installed with following Code) ...

Code: Select all

[iframe]http://www.news.at[/iframe]

Code: Select all

<iframe src={TEXT} width="550" height="330"  frameborder="0" scrolling="no"></iframe>
.. my Browser loads the whole page that I refer to (news.at) instead of displaying the iFrame-Box within the posting?

Can anybody help me?

Re: URL problem in BBCode

Posted: Tue Jun 12, 2007 1:21 pm
by dark/Rain
That's because of this code in their (main) page:

Code: Select all

<script language="JavaScript" type="text/javascript"><!--
if (self!=top) { top.location.replace(self.location.href); }
//--></script>
That frees the page out of framesets/iframes.

Re: URL problem in BBCode

Posted: Tue Jun 12, 2007 1:43 pm
by Youvan
dark/Rain wrote:That's because of this code in their (main) page:

Code: Select all

<script language="JavaScript" type="text/javascript"><!--
if (self!=top) { top.location.replace(self.location.href); }
//--></script>
That frees the page out of framesets/iframes.
oh thanx!
But then I don't understand, why my iframe-BBCode reacts the same way, when i wanted to embed online games from http://www.freeonlinegames.com!? They officially support embedding their online games!

Code: Select all

[gameid]{TEXT}[/gameid]

Code: Select all

<frame width="550" height="330" src="http://www.freeonlinegames.com/embed.php?g_id={TEXT}" frameborder="0" scrolling="no"></frame>
e.g. I tried to embed this free online game in a posting: http://final-fight.freeonlinegames.com/

but it doesn't work either. The iframe-Bbcode reacts like a normal link to the freeonlinegames.com -Page?!

Re: URL problem in BBCode

Posted: Tue Jun 12, 2007 2:04 pm
by dark/Rain
Is it intended that you used "frame" instead of "iframe" for this one? (That won't work...)

Re: URL problem in BBCode

Posted: Tue Jun 12, 2007 2:21 pm
by Youvan
dark/Rain wrote:Is it intended that you used "frame" instead of "iframe" for this one? (That won't work...)
oh my god!
sorry, but it was because of testing a few possibilites before :oops:

I'm sure I've already tested the same code with the right "i"frame a few times, but it didn't work!
BUT now, after adding the "i" after your tip it works perferct! :?:
However: thanks for your support!

So that's the code which definitely WORKS (in my case ;) ) now:

Code: Select all

[game]{TEXT}[/game]

Code: Select all

<iframe width="550" height="330" src="http://www.freeonlinegames.com/embed.php?g_id={TEXT}" frameborder="0" scrolling="no"></iframe>
perhaps it was a question of board-cache? :roll:

Re: URL problem in BBCode

Posted: Tue Jun 12, 2007 3:19 pm
by dark/Rain
Youvan wrote:perhaps it was a question of board-cache? :roll:
It shouldn't... (?)
Anyway, strange things happen... :mrgreen:
Great that it works now. :)

Re: URL problem in BBCode

Posted: Thu Jun 14, 2007 9:01 pm
by IBBoard
I've just encountered the same problem ("<!-- m -->..." and auto-parsing of URLs within custom BBCode) and I found what I think is probably the 'correct' solution.

Basically, after sticking in a load of echos to track what was happening, the [img] tag was convertion http://... to http&#58;//..., and replacing dots with &#46;, but the custom BBCode didn't replace the characters and so it was then picked up by this section of the makeClickable function:

Code: Select all

'#(^|[\n\t (>\]])(' .
That's the start of the regex, and it specifically says "or if the URL is preceeded with the start of a line, new line, tab, space, opening bracket or closing square bracket (which custom BBCode using URLs will be) then make it clickable". karlsemple's code works by stoping the clickable function matching the closing bracket.

My solution (only on a development board so far, so not fully tested) is:

Open includes/acp/acp_bbcode.php

Find:

Code: Select all

			'URL'	 => array(
				'!([a-z0-9]+://)?([^< "\r\n\t\]]*)!ie'	=>	"(('\$1') ? '\$1\$2' : 'http://\$2')"
			),
replace with:

Code: Select all

			'URL'	 => array(
				'!([a-z0-9]+://)?([^< "\r\n\t\]]*)!ie'	=>	"\$this->bbcode_specialchars((('\$1') ? '\$1\$2' : 'http://\$2'))"
			),
That then makes the {URL} token behave in the same way as the [url] tag uses it, so you shouldn't get any clickable issues as http:// should now be http&#58;// and so clickable won't match it.

Hopefully that makes sense and helps people :) One thing to note is that it'll only affect future postings and might not convert back correctly (e.g. editing old and incorrect BBCodes) - that's still to be tested.


[edit] Just a quick update - it seems to work with existing 'broken' tags as well, so editing a post with a broken tag should fix it after the code change.

[edit] 19th August - opened a new bug because the old one had been closed without resolving the situation I posted above (or a similar one) so I checked back and corrected "acp/acp_bbcode.php" to "includes/acp/acp_bbcode.php".

Re: URL problem in BBCode

Posted: Fri Jun 15, 2007 5:18 pm
by cutaia
IBBoard wrote:A bunch of stuff that seemed to make sense...
Can anyone confirm that this is the correct solution to this problem? Also, does anyone know if this is being considered a bug to be fixed?