Test and find a flaw in this.

Soldato
Joined
12 Jun 2005
Posts
5,361
Hi there,

I am creating the add bit of my CMS and I am parsing the text that is put in. The function i have created is supposed to do the following:

  • Put it in valid xHTML
  • Put it in paragraphs where appropriate.
  • Put linebreaks where appropriate.
  • Strip any unnecessary line breaks and paragraphs.
  • Use BB Code (this won't product valid HTML yet as i haven't done that bit yet, but it should still display ok)

So could you test it and see if it's doing what its supposed to:

http://customised.live-host.org/test.php

Thanks.
 
Caporegime
Joined
18 Oct 2002
Posts
29,491
Location
Back in East London
Just a note that no matter how trivial it may seem.. attempted 'hacking' whether consented or not is still illegal in a number of places, the UK included.

But don't expect SO19 to be knocking on your door.
 
Soldato
OP
Joined
12 Jun 2005
Posts
5,361
Hi peeps....

Sorry for not explaining very well.

Basically, I want the articles to be formatted properly.

So instead of using a conventional nl2br() function (which would just have <br />'s all over the place), I have created my own which formats the text in paragraphs (how it should be done).

Just wanted to check it works properly.

Thanks for looking.
 
Soldato
Joined
18 Oct 2002
Posts
5,464
Location
London Town
Seems fine so far.

I notice slashes are being escaped, which wouldn't be desirable behaviour - may be worth doing a quick check while parsing if you're not already doing this in the proper app.
Code:
this is a slash \
=
Code:
this is a slash \\

Additionally, i18n strings such as:
Code:
東京事変
are converted to their character entity equivalent, but appear to be double-escaped, incorrectly producing:
Code:
<p>&amp;#26481;&amp;#20140;&amp;#20107;&amp;#22793;</p>
 
Permabanned
Joined
21 Dec 2006
Posts
127
I like the fact it splits by <p> rather than using <br />, but the stripping of linebreaks means I can't double space, which I think if you've got a lot of text split by titled paragraphs would be needed.
 
Soldato
OP
Joined
12 Jun 2005
Posts
5,361
Augmented said:

Thanks.

I am not sure exactly why its adding slashes because i havent run the addslashes or mysql escape functions anyways, but when i run the stripslashes() function it removes that. Thanks.

I can't seem to reproduce the second point you made.


EDIT:

I think i have fixed this.
 
Last edited:
Soldato
OP
Joined
12 Jun 2005
Posts
5,361
paulsheffII said:
I like the fact it splits by <p> rather than using <br />, but the stripping of linebreaks means I can't double space, which I think if you've got a lot of text split by titled paragraphs would be needed.

Do you mean double space between paragraphs...yeah?

I could just remove the part where it removes:
Code:
<p><br />
...that will let you double space.
 
Soldato
OP
Joined
12 Jun 2005
Posts
5,361
Have updated this now (see link).

It should use BB code: quote, url, bold, italic, underline and format them properly with valid xHTML.

Also fixed any issues stated in this thread. Thanks to those that pointed them out (+solutions).

It also now formats the HTML so when you view the source it's layered.

If anyone else notices anything wrong/needs updating/.... just say....

Thanks for looking.
 
Back
Top Bottom