BBCode Parser Testing ?

Talk about anything in here.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

BBCode Parser Testing ?

Post by jacek »

So I think I have the BBCode parser for XHBB pretty much perfected and could do with some free testing if you are interested, this is the most likely place to have security (XSS) issues so it needs some serious testing :)

If you are interested go to this link http://jacekk.co.uk/bbcode_test/

The the test button will log what you enter and the processed result to mysql so I can look later, it will also show you the result :)

Valid tags are

[syntax=text][b]test[/b] for bold
[u]test[/u] for underline
[i]test[/i] for italic
[s]test[/s] for line-through
[img]url[/img] for an image
[url]url[/url] for a link[/syntax]
The url tag is a little different to most common ones at the moment as you can also do

[syntax=text][url url="url" title="hover text"]thing to show[/url][/syntax]
either attribute should be optional, if url is left out the thing inside the tag is used. because of the way it detects the thing inside the tag you can also do

[syntax=text][url][img]url[/img][/url][/syntax]
to link to the same image that is displayed. And because the forum will resize large images by default, this is a nice way to easily do click to enlarge :)

The parser should also try to sort out any tags in the wrong order, so if you do
[syntax=text][b]test[/syntax]
it will do bold text as it auto-closes tags left open,

Also if you do

[syntax=text][b]test[/i][/syntax]
the [/i] will be replaced with a [/b]

The overall aim is to keep the html valid, so if you invalidate it somehow, you win :lol:

So a summery of what you should do:
- Go to http://jacekk.co.uk/bbcode_test/
- Try to break it by:
- Looking for XSS exploits
- Trying to invalidate the html by entering mangled bbcode

Thanks in advance, it would be a great help if you could have a go :)

If you find anything interesting, post your test # here so I can look in the DB
Image
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: BBCode Parser Testing ?

Post by Tino »

:?

<script type="text/javascript">alert('most simple test');</script>

gave me a pop-up.

By the way, I think, for the URL tag, you should do it just like any other forum does it. You're sort of inventing your own BBCode, which is fine, but I don't think you should do it with such universal tags. Personally I'd just stick to

[syntax]text[/syntax]

just so that everyone knows what to use right off the bat.
Please check out my CodeCanyon items.
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: BBCode Parser Testing ?

Post by bowersbros »

well, if the title="" is optional, it doesnt matter, and it allows more info to be given which i like so, i think keep it. since having it wont affect anything
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
EcazS
Posts: 789
Joined: Fri May 06, 2011 5:29 pm

Re: BBCode Parser Testing ?

Post by EcazS »

I love that if you do Test[/b ][/i ] it still get's it right and closes in the "valid" order :D

Now you just need a syntax highlighter :lol:
Last edited by EcazS on Tue Jun 07, 2011 11:34 am, edited 1 time in total.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

Tino wrote:<script type="text/javascript">alert('most simple test');</script>

gave me a pop-up.
oo... I forgot a htmlentities :lol: fixed. that was a bug in the page that I made for testing, not the parser ;)
Tino wrote:By the way, I think, for the URL tag, you should do it just like any other forum does it. You're sort of inventing your own BBCode, which is fine, but I don't think you should do it with such universal tags. Personally I'd just stick to
because of the way it works would be impossible [url]link Is still the same ;) SMF has totally crazy BBCode compared to phpbb.
EcazS wrote:I love that if you do Test[/b ][/i ] it still get's it right and closes in the "valid" order :D

Cleaver right ;)
Image
User avatar
EcazS
Posts: 789
Joined: Fri May 06, 2011 5:29 pm

Re: BBCode Parser Testing ?

Post by EcazS »

jacek wrote:
EcazS wrote:I love that if you do Test[/b ][/i ] it still get's it right and closes in the "valid" order :D

Cleaver right ;)


Very clever indeed... and awesome :lol:
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

[b][i]Test[/b][/i]

For this example what actually happens is that it gets to the [/b] tag, realises the last opened tag was [i] and removes the [/b]. Then the auto-closing puts the [/b] back as it ends up being left open.
Image
User avatar
EcazS
Posts: 789
Joined: Fri May 06, 2011 5:29 pm

Re: BBCode Parser Testing ?

Post by EcazS »

jacek wrote:it gets to the [/b] tag, realises the last opened tag was and removes the [/b]. Then the auto-closing puts the [/b] back as it ends up being left open.


:shock:
I'm speechless. That is freakin' awesome.

And how did you type that without it turning into a bold, italic text :shock:
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

EcazS wrote:And how did you type that without it turning into a bold, italic text :shock:
There is a disable BBCode checkbox under the preview and submit buttons. Weirdly it does not disable the syntax tags, which is how I made the first post in this topic :D
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

The Test # is now a link, e.g. this is my favourite so far http://jacekk.co.uk/bbcode_test/?test_id=12 8-)
Image
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: BBCode Parser Testing ?

Post by bowersbros »

http://jacekk.co.uk/bbcode_test/index.php?test_id=30

It only autocloses one, maybe try to get it to autoclose all? :)
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

bowersbros wrote:http://jacekk.co.uk/bbcode_test/index.php?test_id=30

It only autocloses one, maybe try to get it to autoclose all? :)
What do you mean ? the i and u tags are both auto-closed in this example.
Image
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: BBCode Parser Testing ?

Post by bowersbros »

jacek wrote:
bowersbros wrote:http://jacekk.co.uk/bbcode_test/index.php?test_id=30

It only autocloses one, maybe try to get it to autoclose all? :)
What do you mean ? the i and u tags are both auto-closed in this example.
oh yes, didnt see the </em> :P
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

bowersbros wrote:oh yes, didnt see the </em> :P
Did it not look italic ? :?

I thought you were talking about the [/s] tag, auto-opening as well would be harder :lol:

As long as it produces valid html I am happy :) you're not really meant to rely on the auto-closing anyway, it's just a cool way to make the html stay valid.
Image
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: BBCode Parser Testing ?

Post by bowersbros »

can you share the code you use for auto closing? :D
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: BBCode Parser Testing ?

Post by Temor »

jacek wrote:The Test # is now a link, e.g. this is my favourite so far http://jacekk.co.uk/bbcode_test/?test_id=12 8-)
I tried really hard to break it!

You did a really good job Jacek! Well done.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

bowersbros wrote:can you share the code you use for auto closing? :D
Already shared https://github.com/betterphp/XHBB/blob/ ... ss.inc.php around line 255 The validate_tokens() method one line 188 is the thing you are testing :)

I know it's embarrassingly messy !
Temor wrote:I tried really hard to break it!

You did a really good job Jacek! Well done.
I assume you didn't mange :) that's good :D Also thanks.
Image
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: BBCode Parser Testing ?

Post by Temor »

jacek wrote: I assume you didn't mange :)
Nope. I even googled for usual custom bbcode glitches and bugs, but none of the ones I found glitched your code.

It's flawless :)
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

Temor wrote:It's flawless :)
Well that sounds promising. thanks for testing so thoroughly
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: BBCode Parser Testing ?

Post by jacek »

Image
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: BBCode Parser Testing ?

Post by bowersbros »

http://jacekk.co.uk/bbcode_test/index.php?test_id=43

maybe get it to ignore parameters? so the first one doesnt show [hello] but instead hello.

And also, got a random pair of [ ] between my content for invalid tag use.
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Post Reply