Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
Scream,

sorry to bother you again:

Our friend, the MAC/IE -line break bug, is still there.

Sponsored Links
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
I still haven't been able to figure this one out. According to the php manual the fucntions I'm using are supposed to catch all forms of line breaks. But, it's hard to test this since I don't have a mac. Anyone know if there is a browser emulator for this?


UBB.threads Developer
Sally #215261 04/21/2002 1:52 PM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
Scream,

I think I found it!!!!

AND THE WINNER IS...........


In Addpost.php,

replace


// ---------------
// Add break tags
$PrintBody = str_replace("\n","<br>",$PrintBody);

by


// ---------------
// Add break tags
$PrintBody = str_replace("\n","<br>",$PrintBody);
$PrintBody = str_replace("\r","<br>",$PrintBody); //HACK MAC


and


// ---------------
// Add break tags
$Body = str_replace("\r","<br>",$Body);

by


// ---------------
// Add break tags
$Body = str_replace("\n","<br>",$Body);
$Body = str_replace("\r","<br>",$Body); //HACK MAC


Mac uses different line breaks than Unix and PC.
A browser should be able to convert that right, but IE5 obviously doesn't. I tried different special symbols in REgular expressions, and \r dit it...

If you put it in this beta to all occurences of a break-replace, i could try it out here..
I am sure that my code at least will not harm []/forum/images/icons/wink.gif[/]

Last edited by caymuc; 04/21/2002 1:52 PM.
rodrigo1 #215262 04/21/2002 1:57 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Now that you mention this I know I have read something about this elsewhere... not sure where though. LoL (that is about having the \r return carriage after the \n new line for Mac IE. Mac NS ok too?

Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
Mac/NS never had a problem with that problem.

That is only Mac/IE releated (...with compliments from Bill []/forum/images/icons/grin.gif[/] ).

Last edited by caymuc; 04/21/2002 2:07 PM.
Sponsored Links
rodrigo1 #215264 04/21/2002 4:49 PM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
Right thinking,
too quick the "solution"... []/forum/images/icons/blush.gif[/]

My code works for MAC now, but not for PC this time,
it seems to add extra <br> sometimes there...

I play around and try to come with something better.


Last edited by caymuc; 04/21/2002 5:00 PM.
rodrigo1 #215265 04/21/2002 4:53 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Does the Mac have bot \r\n at the end of the strings?

Why not remove the \r and line break the \n ?

(that's only if it has both) []/forum/images/icons/smile.gif[/]

rodrigo1 #215266 04/21/2002 5:12 PM
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Ok, I think I'll need to change the regex so it just matches one and not both. Thanks for the fix!


UBB.threads Developer
Sally #215267 04/21/2002 5:14 PM
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Ok, this should do it:

$Body = eregi_replace("(\n|\r\n)","<br />",$PrintBody);


UBB.threads Developer
Sally #215268 04/21/2002 5:48 PM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
not working

MAC/IE uses /r (chr13) INSTEAD of /n

I found out


Sponsored Links
rodrigo1 #215269 04/21/2002 6:05 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
So it should be this:

$Body = eregi_replace("(\r|\n|\r\n)","<br />",$PrintBody);


(maybe even throw in a \n\r for good measure) []/forum/images/icons/smile.gif[/] LoL

rodrigo1 #215270 04/21/2002 6:05 PM
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Ok, to cover all bases, we could use:

$Body = eregi_replace("(\n|\r\n|\n)","<br />",$PrintBody);


UBB.threads Developer
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Beat me to it []/forum/images/icons/wink.gif[/]


UBB.threads Developer
Sally #215272 04/21/2002 6:07 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
just thinking... shouldn't \r\n come first as the other two will modify \r\n seperately?

Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Hmm, you might be right on that. Should change it that way just to be safe.


UBB.threads Developer
Sally #215274 04/21/2002 6:12 PM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
2 options with \n ?

Are the options in RegEx read from right to left?

Not that /n is replaced, before /r/n is checked?

rodrigo1 #215275 04/21/2002 6:15 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Try

$Body = eregi_replace("(\r\n|\n|\r)","<br />",$PrintBody);

Does the back slash need to be made literal? that is \\r\\n|\\n|\\r ?

rodrigo1 #215276 04/21/2002 6:37 PM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
Tested this code POSITIVE on Mac(9.1) AND PC
for both IE5 and NS4.x
(tested for New message with Preview and Change Message):


$Body = eregi_replace("(\n\r|\r\n|\r|\n)","<br>",$Body); //HACK MAC (Vers. 5.5.1!)


Not tested yet on Unix, unicode, MacOS 10,
but I believe it works there too.

I think I have one option to much in it, but it does not hurt this time, and this time it seems to be the right order of the options...


rodrigo1 #215277 04/21/2002 6:50 PM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374

eregi_replace("(\r\n|\r|\n)","<br>" ...

seems to work too (one option less...)


Now I changed the code in:

addpost.php

changebasic.php
mess-reply.php
modifypost.php
previewedit.php
sendmessage.php
showflat.php
showthreaded.php

I do not think it was always necessary here besides addpost, but i did it anyway... Am I right with this?




rodrigo1 #215278 04/29/2002 1:29 PM
Joined: Oct 2000
Posts: 60
Power User
Power User
Offline
Joined: Oct 2000
Posts: 60
OK, I'm going to clarify this even though this has already been fixed.

In text files...
UNIX systems use the New Line character (\n) at the end of each line
Mac systems use the Carraige Return character (\r) at the end of each line
DOS/Windows systems use Carraige Return and New Line character (\r\n) at the end of each line

It seems that web browsers inherit this from their OSes.

Bommer #215279 04/29/2002 2:59 PM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
You would not believe how happy I am that this bug is finally fixed (I use Mac myself). - From your explanaion I see that our try & error experriments where just right. I wonder when ThreadsDev.com will have that Fix installed (hint hint) *g*

rodrigo1 #215280 04/29/2002 8:17 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
I'm a mac user too.. But I'm confused as to exactly what lines of code to change to what in the files you've listed.... or will Rick put this in the upcoming release? Will your fix work on 5.5.1??? Love to get this fixed for my own use ASAP.

Daine #215281 04/30/2002 2:15 AM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
The fix works well in 5.5.1. - I run it on my forums and no problems ever since with it here.

I am sure Scream put it in V.6. as this bug was annoying for all of us. And as I heard we can expect V.6. in a couple of days already.

If you don't want to update anyway, I can write here accurate instructions to hack 5.5.1: write me a mail...

rodrigo1 #215282 05/01/2002 12:34 PM
Joined: Jul 2001
Posts: 12
Newbie
Newbie
Offline
Joined: Jul 2001
Posts: 12
What i'm surprised at is that the PHP nl2br() function doesn't handle for all of those cases - only \n.

rodrigo1 #215283 05/01/2002 1:20 PM
Joined: Jan 2001
Posts: 374
Enthusiast
Enthusiast
Offline
Joined: Jan 2001
Posts: 374
Due to public request:
My fix would be like this for 5.5.1:

Search fot this string in all documents
(MAC BBEdit use "Multifile Search in Folder"):

[:red]str_replace("\n","<br>",[/]

Replace that with this string:

[:red]eregi_replace("(\r\n|\r|\n)","<br>",[/]

The searched/replaced code is a part string of other code,
make sure you do not touch the rest.
Done.

(Use usual precortions: make a backup of all code first, just in case something goes wrong!)


Scream, and others here, please correct me if I am wrong. []/forum/images/icons/smile.gif[/]


Greetings

Last edited by caymuc; 05/01/2002 1:30 PM.

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Nettomo
Nettomo
Germany, Bremen
Posts: 417
Joined: November 2001
Forum Statistics
Forums63
Topics37,575
Posts293,930
Members13,823
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)