URL problem in BBCode

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Get Involved
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
sikita
Registered User
Posts: 47
Joined: Tue Jun 29, 2004 9:40 am

URL problem in BBCode

Post 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
User avatar
karlsemple
Former Team Member
Posts: 39802
Joined: Mon Nov 01, 2004 8:54 am
Location: Hereford, UK
Contact:

Re: URL problem in BBCode

Post 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>
Image
sikita
Registered User
Posts: 47
Joined: Tue Jun 29, 2004 9:40 am

Re: URL problem in BBCode

Post 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>
User avatar
karlsemple
Former Team Member
Posts: 39802
Joined: Mon Nov 01, 2004 8:54 am
Location: Hereford, UK
Contact:

Re: URL problem in BBCode

Post 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?
Image
sikita
Registered User
Posts: 47
Joined: Tue Jun 29, 2004 9:40 am

Re: URL problem in BBCode

Post by sikita »

Yes, it is working... why it is not working between tags? [iframe]www.xxx.com[/iframe] ?
User avatar
karlsemple
Former Team Member
Posts: 39802
Joined: Mon Nov 01, 2004 8:54 am
Location: Hereford, UK
Contact:

Re: URL problem in BBCode

Post 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.
Image
dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: URL problem in BBCode

Post 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)...
User avatar
Youvan
Registered User
Posts: 49
Joined: Thu May 03, 2007 3:00 pm

Re: URL problem in BBCode

Post 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?
dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: URL problem in BBCode

Post 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.
User avatar
Youvan
Registered User
Posts: 49
Joined: Thu May 03, 2007 3:00 pm

Re: URL problem in BBCode

Post 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?!
dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: URL problem in BBCode

Post by dark/Rain »

Is it intended that you used "frame" instead of "iframe" for this one? (That won't work...)
User avatar
Youvan
Registered User
Posts: 49
Joined: Thu May 03, 2007 3:00 pm

Re: URL problem in BBCode

Post 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:
dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: URL problem in BBCode

Post 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. :)
User avatar
IBBoard
Registered User
Posts: 542
Joined: Wed May 25, 2005 9:02 pm
Location: Worcestershire, UK
Contact:

Re: URL problem in BBCode

Post 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".
Last edited by IBBoard on Sun Aug 19, 2007 6:05 pm, edited 1 time in total.
cutaia
Registered User
Posts: 76
Joined: Sun Mar 06, 2005 3:35 am

Re: URL problem in BBCode

Post 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?
Locked

Return to “[3.0.x] Support Forum”