php forum
php mysql forum
php mysql smarty
 
Page 2 of 2 < 1 2
Topic Options
#222621 - 08/21/02 02:38 PM Re: </font color> [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala

   Re: </font color> to Del.icio.us Add to del.icio.us
  Digg Re: </font color> Digg it
I still can't see how the regex can now which font closing tag it should parse? <br /><br />Maybe my example was a bad one, since you could merge them into one markup tag like you have. But that wasn't the point. The point being that if different markups both have the </font> the regex will have no way of knowing which one is the one that it should match to. Some amazing things can be done with regexes, but magic isn't one of them. =]<br /><br />Testing your code shows that the following happens:<br />Initially:<br /><font style="courier"><font color="red"><font size="5"> Red courier, size 5 </font></font></font><br /><br />After iteration 1: <br />[font style="courier"]<font color="red"><font size="5"> Red courier, size 5 [/font]</font></font><br /><br />After iteration 2: <br />[font style="courier"][font color="red"]<font size="5"> Red courier, size 5 [/font][/font]</font><br /><br />After iteration 3: <br />[font style="courier"][font color="red"][font size="5"] Red courier, size 5 [/font][/font][/font]<br /><br />In this case it doesn't matter that much of course, but it shows that the replace is done with the first possible match. If the </font> tag is part of something else, it will break, and it could potentially screw up the nesting as well.
_________________________
/Gardener | Complete list of my mods

Top
#222622 - 08/21/02 02:57 PM Re: </font color> [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Hmmmmmm, you're right, that code does behave as you describe.<br /><br />I did some fairly complex tests for that hack, and couldn't break it, but maybe I didn't find the right test case.
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222623 - 08/21/02 03:15 PM Re: </font color> [Re: joeuser]
JustDave Offline
That 70's Guy

Registered: 06/24/01
Posts: 4097
Pages that display posts, such as showflat.php could have the </font color> tag converted to </font> to remain standards compliant.<br /><br />Just prior to this:<br /><br />$postrow[$i]['Body'] = $Body;<br /><br />You could use this:<br /><br />$Body = str_replace("</font color>","</font>",$Body);<br /><br />Then the browser would recieve compliant code for viewing and custom tags could remain for editing and other such purposes.<br /><br /><br />Am I missing something with all of this? I think I'm understanding that the main goal is to have the html that is displayed be standards compliant. How the html is handled on the backend prior to display shouldn't make a difference. (IMHO) <img src="/forum/images/icons/smile.gif" alt="" />
_________________________
~Dave
ChattersOnline.com

Top
#222624 - 08/21/02 03:32 PM Re: </font color> [Re: sjsaunders]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
I'd prefer to use <!--color--></font> instead of </font color>. I think it's simpler to make the posts that are stored in the database correct HTML. Then you don't have to worry about special conversions whenever you want to display them.
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222625 - 08/21/02 03:33 PM Re: </font color> [Re: sjsaunders]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
That's what we've all said as well, but then we went on about discussing if we could have the non-compliant html removed completely.<br /><br />It would be nice to not have to do that extra replace for the color tag (and the others that I have in the markuphack), but it works.
_________________________
/Gardener | Complete list of my mods

Top
#222626 - 08/21/02 03:55 PM Re: </font color> [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
True, it would be nice if the correct html was in the database as well. And the html comment should work perfectly OK.<br /><br />Here's the code for this if anyone wants it, do the following in ubbt.inc.php:<br />Find this line:<br /><pre><font class="small">code:</font><hr><br /> $matches[0][$i] = preg_replace("/\[\/{$ubbt_lang['COLOR']}\]/","</font color>",$matches[0][$i]);<br /></pre><hr><br />Change it to this:<br /><pre><font class="small">code:</font><hr><br /> $matches[0][$i] = preg_replace("/\[\/{$ubbt_lang['COLOR']}\]/","<!-- color --></font>",$matches[0][$i]);<br /></pre><hr><br />Find this line:<br /><pre><font class="small">code:</font><hr><br /> $Body = preg_replace("/\[\/{$ubbt_lang['COLOR']}\]/","</font color>",$Body);<br /></pre><hr><br />Change it to this:<br /><pre><font class="small">code:</font><hr><br /> $Body = preg_replace("/\[\/{$ubbt_lang['COLOR']}\]/","<!-- color --></font>",$Body);<br /></pre><hr><br />Find this line:<br /><pre><font class="small">code:</font><hr><br /> $Body = preg_replace("/<\/font color>/i","[/{$ubbt_lang['COLOR']}]",$Body);<br /></pre><hr><br />And change it to this:<br /><pre><font class="small">code:</font><hr><br /> $Body = preg_replace("/<!-- color --><\/font>/i","[/{$ubbt_lang['COLOR']}]",$Body);<br /></pre><hr><br /><br />But after this is done, the color markup won't be parsed correctly when changing posts done with the old way. But I guess it should work by adding the given lines instead of replacing the old line, that way even old posts should be parsed correctly during editing. Haven't tested it though.
_________________________
/Gardener | Complete list of my mods

Top
#222627 - 08/21/02 04:13 PM Re: </font color> [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Not meaning to be too picky, but before this gets "standardized", do you think <!--color--> (no spaces) would be better than <!-- color -->? <img src="/forum/images/icons/smile.gif" alt="" />
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222628 - 08/21/02 05:01 PM Re: </font color> [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Don't know, I always have a space before/after the --, I think some ancient browser broke if this wasn't the case. Not sure though, but I just do it by habit, removing the spaces should probably be OK and might be better for the parsing.<br /><br />Also, only the code in the undo_markup should be added instead of replaced. Thus making sure that old posts are editable (is that a word? =]), but all new posts use the new markup.
_________________________
/Gardener | Complete list of my mods

Top
#222629 - 08/22/02 03:20 PM Re: </font color> [Re: c0bra]
mod_perl Offline
Newbie

Registered: 08/15/02
Posts: 16
I don't mind being wrong when it sparks such a useful discussion. <img src="/forum/images/icons/wink.gif" alt="" /> <br /> <br />I solved this problem by disabling color markup since it clashes with stylesheets, and discourages those who like to distinguish themselves by posting in all violet text. Crude but effective.

Top
#222630 - 08/22/02 04:59 PM Re: </font color> [Re: jjski]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
That's one way of fixing the problem of course. =] If my users would start setting the color of all the text in their posts and change font styles etc I would definetely remove the function. But at the moment it's only used in signatures, or to highlight some small bits of text. But before I'd remove it completely I'd try to convince users that are overusing those markups to stop.
_________________________
/Gardener | Complete list of my mods

Top
Page 2 of 2 < 1 2


Who's Online
0 Registered (), 22 Guests and 8 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Team UBBDev Rides Again!
by AllenAyres
Yesterday at 01:36 PM
Blogs, love em or hate em?
by AllenAyres
10/07/08 02:05 PM
What do you use to edit the files
by Ian_W
10/05/08 03:33 PM
BeyondCompare v3.00
by Ian_W
10/05/08 03:32 PM
Glossy Black Theme with Image Reflection
by Gizmo
10/05/08 02:17 PM
ShareThis
by Gizmo
09/28/08 05:06 AM
[7.3] Viewing MySQL logfiles made easier
by AllenAyres
09/27/08 09:57 PM
New Mods
[7.3] Viewing MySQL logfiles made easier
by blaaskaak
09/24/08 05:39 PM
[7.3.1] add search to showmembers page
by blaaskaak
09/07/08 04:50 AM
Newest Members
Kevs, pisa666, ghengis317, NitroX, Dogan
13346 Registered Users
Top Posters Last 30 Days
AllenAyres 11
blaaskaak 6
Chris Bale 4
Gizmo 4
FREAK1 4
Ian_W 4
tackaberry 4

 

 

 
fusionbb message board php hacks