Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 12:54 pm EST

Geeklog Forums

Faqman and carriage returns


Status: offline

akerin

Forum User
Junior
Registered: 08/22/02
Posts: 19
I'm using the Faqman on our corporate intranet, and I'm running into one problem. If I copy code into the answer text box that has carriage returns in it, e.g.:

<b
> test this


or


Here's
some text


I get this when I show the FAQ answer:

> test this

and

Here's
some text

even though there's no html line break in there. This happens in Mozilla and IE, with htmlarea and without.

Any one else seen this? - Can't show you an example as it's a closed site.

Alex Kerin

 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
surprised
I recall having a similiar problem many months ago when I was first working on this plugin. I was not sure if I had addressed it before I released the initial version. I just tried a clean install of the faqman and created two test topics where I pasted content from a webpage news article and another using content from MS Word.

In both tests, I did not get any extra line breaks. All line spacing was preserved ok. It's as if normal line breaks are being converted to <br> tags which the PHP function nl2br() will do. The original code had this but I removed it as I recall and my testing above confirmed.

Have you tried various tests from other sources as well?
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

akerin

Forum User
Junior
Registered: 08/22/02
Posts: 19
Looking at the resulting source code it does look like that is happening, though a grep search in my faqman directory, brings up no instances of nl2br in the code. I\'ve tried pasting from word, and just writing the html into the form area.

Both result in the extra br tags. For eaxmple: this in the form:

what

is

happening??

<b
> bolder

Goes to this when viewing the source:

what <br><br>is <br><br>happening??<br><br><b><br>> bolder

Cheers, Alex

 Quote

Status: offline

akerin

Forum User
Junior
Registered: 08/22/02
Posts: 19
Ok, I have found a fix - looking at the database, the answer text was being inserted into the database with the return and new line characters still in there. The addition of the &lt;br&gt;s was happening later, somewhere else, possibly by htmlarea as a I edited the FAQ again, so this was not the problem.

To fix this, which seems to work so far, I added the following:

$answer = str_replace(&quot;r&quot;, &quot;&quot;, $answer);
$answer = str_replace(&quot;n&quot;, &quot; &quot;, $answer);

(there is a slash before the r and n that are stripped out by the forum)

at line 136 in topics.php - after this:
$question = str_replace(&quot;&quot;&quot;, &quot;&quot;&quot;, $question);

(similarly, there is a slash within the quotes)

This strips out the carriage and new line returns.

Alex
 Quote

All times are EST. The time is now 12:54 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content