The title pretty much says it all.

Comments

philosurfer’s picture

getting the same problem. The string is not converting carriage returns to html for the JS.

philosurfer’s picture

Assigned: Unassigned » philosurfer
Status: Active » Needs review
StatusFileSize
new576 bytes

here is a patch that strips hard returns from the paragraph strings

philosurfer’s picture

Status: Needs review » Patch (to be ported)
reg’s picture

Instead of stripping NL's can't you use nl2br() so people can still format extra lines if they want? That would be nicer to the user.

philosurfer’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new608 bytes

good call i was half asleep when i did this...

fyi.. the nl2br() doesnt see the hard returns properly, so using a str_replace() was still mandatory to get needed effect :D

I think there is better way to do this, scrubbing strings before passing them to JS... as soon as i find it, Ill post a third patch.

in the meantime.. here is this :)

philosurfer’s picture

Status: Needs review » Patch (to be ported)
reg’s picture

Just looking at the code I see one problem in that different OS's are going to produce a different number of new lines (BR's). You might want to use Regex to convert all \r\n to to \n and \r to \n and then do a conversion to the HTML BR tag from \n or something with similar logic. With the code you have you will get 2 new lines on some OS's and one new line on others since between Linux, Mac & Window you get all three combinations.

However, as far as I know that is exactly what nl2br (http://us.php.net/manual/en/function.nl2br.php) does so I don't know what you mean by it doesn't see the hard returns properly. It's a pretty standard function that's been around forever.

entendu’s picture

Status: Patch (to be ported) » Fixed

@Reg, nl2br() sees the returns properly, but it doesn't replace them -- it only adds a <br />. So this:

foo\nbar

turns into this:

foo<br />\nbar

which still breaks the js.

I committed @philosurfer's patch with one modification, I added "\r\n" to the needle array. That should get us going!

reg’s picture

Good solution.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.