corzblog bbcode parser preview



Here it is! My [search engine fodder] bbcode to html parser, and html to bbcode parser [/search engine fodder]!

This is the actual very onsite parser that parses the bbcode of my blogs and site comments, which as well its usual tasks of, well, you know, the parsing stuff, also moonlights doing a cute wee background demo of itself, you're looking at it. it knew you wanted to do that. hit the "preview" button to see at least one half of the parser's bbcode to html/html to bbcode functionality.

The front-end (below) is built-in to the parser, you just call the function and it creates the form. The cool, super-portable JavaScript bbcode buttons and functions come in the package, too. Have fun. Oh, and by the way, output is 100% pure HTML5, or nice plain bbcode, which ever way you look at it, it's free.

button to undo the last javascript change
cbparser quick bbcode guide..
Most common bbtags are supported, and with cbparser's InfiniTags™ you can pretty much just make up tags as you go along. If cbparser can construct valid html tags out of them, it will. Experimentation is the key, and preview often.

A few bbcode examples..
[b]bold[/b], [i]italic[/i], [big]big[/big], [sm]small[/sm], [img]http://foo.com/image.png[/img], [code]code[/code],[code]teletype[/code], [url="http://foo.com" title="foo!"]foo U![/url], and more.. To post code with indentation and/or strange characters, .htaccess, etc., use [pre][/pre] tags.
download cbparser
an HTML5 compliant bbcode parser



Welcome to the comments facility!


previous comments (sixteen pages)   show all comments

cor - 16.11.07 2:27 pm

Hi Hubble.

It's temtping to jump in with a few potential solutions, but less valuable than first asking.. Have you consulted your php error log?

It's clear that cbparser can handle these characters fine (you just used one), so before I rip it apart, even load it in my text editor, I'll need to know things like; what operating system you are using, what version of cbparser, any log output, errors, is it running alone or embedded in some other page, and so on.

Also, when you say the output is totally blank, do you mean the entire page (i.e. it desn't load at all) or just the area where you expected to see html output from cbparser?

It's not possible to give me too much information!

;o)
(or


Hubble - 16.11.07 4:02 pm

I'm running apache 2.2 with PHP Version 5.2.4 on a Windows XP desktop. Also using MySQL 5.0.

I've checked the error log from apache but it gives no error, I also tried debug error logging but it still was empty. I'm using the 1.2 parser version, but I had it with 1.0 too.
The page is not embedded. Everything on the page loads fine accept the part where the text parsed by the bbparser should be. I also have this all running on the web, but there it works fine. So it's a local problem.

When I remove the special character everything works well.

Hubble


cor - 16.11.07 6:53 pm

Hmm. Is utf-8 enabled on the server, and in your local site? perhaps add this to the .htaccess..
php_value default_charset utf-8
A phpinfo() would let you know the current setting. Not that this should make the output blank.

I'm assuming your system has international language support, too. Not that you should need it for this. It's just a good thing! smiley for :D

Can you hack in and echo the output of these two variables..

<?php
$GLOBALS
['cbparser']['warning_message']
$GLOBALS['cbparser']['state']
?>

.. to see what cbparser's error condition was? Pop it into the foot of the page or something (or run with my debug unit).

What bothers me is the lack of php errors. For cbparser to spit out NOTHING AT ALL takes a fairly error condition. And if that's the case, where's the php error log entry?

Is error logging even enabled? Can you produce another error? Any error? (i.e. intentionally, with another file, by adding some gibberish to its code) and actually physically see the error produced in your log? If your error log is empty, go make php add something, on purpose, to check all is working.

Trouble is, it's easy enough to disable all php error logging and error viewing and then not have a clue what's going on, because php won't tell you, if you tell it not to!

;o)
(or


Hubble - 19.11.07 9:31 am

First thing I tried before changing anything was getting the warning message and state.
The warning message gave nothing but the state returned 5, xss attack or php injection...

My windows system is Dutch and has indeed international language support.

I'm going to try to get more out the logs... <edit-2> I have my php logging on ALL and Apache on DEBUG and the page just doesn't give any errors...
(The logs are not completely empty offcourse, the are lots of minor errors and they are all explainable and have nothing to do with the cbparser or this particular page.)

Can you tell me what that state: 5 means?

<edit>
line 769 : $bb2html = preg_replace("/<\?(.*)\? ?>/is", "<strong>script-kiddie prank: <?\\1 ?></strong>", $bb2html);

I disabled line 769 to test what would happen, and I got this:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\Inetpub\wwwroot\Beuk Horeca\includes\cbparser.php on line 1726

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\Inetpub\wwwroot\Beuk Horeca\includes\cbparser.php on line 1727

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\Inetpub\wwwroot\Beuk Horeca\includes\cbparser.php on line 1727

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\Inetpub\wwwroot\Beuk Horeca\includes\cbparser.php on line 1728

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\Inetpub\wwwroot\Beuk Horeca\includes\cbparser.php on line 1729

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\Inetpub\wwwroot\Beuk Horeca\includes\cbparser.php on line 1729

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\Inetpub\wwwroot\Beuk Horeca\includes\cbparser.php on line 1732

Parse error: syntax error, unexpected $end in C:\Inetpub\wwwroot\Beuk Horeca\includes\cbparser.php on line 2185


<edit3> When I totally remove the lines, there errors are also gone again, it was probably because only half the line was disabled...</edit3>

- tried the htaccess. file with php_value default_charset utf-8
- tried adding AddDefaultCharset utf-8 to httpd.conf
- tried adding to php.ini
- mbstring.language = Neutral; Set default language to Neutral(UTF-8) (default)
- mbstring.internal_encoding = UTF-8 ; Set internal encoding to UTF-8
- mbstring.encoding_translation = On
- mbstring.http_output = UTF-8 ; Set HTTP output encoding to UTF-8

all no success... smiley for :erm:

Thanks for all the help, by the way!

Hubble


cor - 20.11.07 1:50 pm

Hmm. Error 5 is just what it says on the can (and in the notes at the top of cbparser); script-kiddie attack. Though clearly that's not the real issue here, as you aren't trying to input dodgy javascript or php into the textarea, I presume.

I don't know what version you are running; those line numbers lead to the demo text! You can delete ALL that; it's just for the demo here at corz.org, really.

One thing that springs to mind is slashes. Everywhere cbparser has been working and developed has had magic quotes enabled..
php_flag magic_quotes_gpc on
and I do remember noting somewhere that behaviour with it disabled (very rare) was "unpredictable", though I'm in no hurry to look into this, you might want to.

Also, did you try disabling xss protection?

;o)
(or

ps. also, check your editor isn't messing with the file; use a good plain text editor, and ensure characters aren't getting left outside the php tags.


Hubble - 21.11.07 10:21 am

The magic quotes we're off, so I turned it on, but it didn't help. I tried turning of the xss, this still gave no output and the state became 0. I was using the 1.2 parser and also tried yout beta. 1.2.1.

I think I will remove the php engine and reïnstall it to see if my setup might be causing it.

Hubble


Hubble - 21.11.07 11:18 am

I deïnstalled php and apache and removed all files left behind, reïnstalled apache 2.2.6. and php 5.2.5.

The problem is still there, I also uploaded my site to our domain to test it and it works fine online (just to make sure)

If I put in my page:
echo bb2html("øøøøøø",'');
I receive the error: there was no text!

Apache does give an error now but it also gives it when the text has no special character and thus the page parses good;
[Wed Nov 21 11:55:04 2007] [error] [client 192.168.122.163] PHP Warning:  htmlentities() 
[<a href='function.htmlentities'>function.htmlentities</a>]: Invalid multibyte sequence in argument in 
D:\my web\includes\cbparser.php on line 545, referer: http://192.168.122.146/

Because it works online perfectly and it's only occuring on my system I think we shouldn't pay much attention to it, maybe a clean install we resolve it.

Thanks for all the help anyway.

Hubble



cor - 21.11.07 11:51 am

Och well. You might want to try..

<?php
$bb2html
= htmlentities($bb2html, ENT_NOQUOTES); ?>

note, no utf-8. I've seen that throw up errors before, but php usually carries on gracefully.

It is a pain when things don't work. I haven't seen this sort of trouble with cbparser before; it sure is used in a lot of places, inside various CMS and all sorts, so I'm guessing you've got something local going on. I wish I could be more help in pinning it down.

The next time I dive into cbparser, will probably be a ground-up rewrite, so I'm leaving it well alone for now!

for now..

;o)
(or


Sony AK - 17.02.08 5:02 pm

Dear bbcode creator,
I'm using your script for my wap site http://m.mobitrek .com/ (using XHMTL mobile spec) on some occasion your script is running well, but when user type wrong ordered tag, then it produces error, the tag sample is like this haha then it will error, can u add some tag order check before?

Thanks.

Sony AK
sony-ak@phpindonesia.com


amir - 26.02.08 4:56 pm

hi,

can u plz post an installation guide? cuz i'm all messed up and i just couldn't install this usefull editor...

many thanks!


cor - 28.02.08 11:21 am

Sony AK, cbparser will check for certain things, unclosed tags and such, but it won't teach people the basic concepts of bbcode. Your example works just fine. Feel free to drop an example that doesn't work, I'll get a better idea of exactly what you mean.

amir, throw the script into a text editor - voluminous notes and instructions are provided within. You should be in there setting your prefs, anyway.

Never run a script without first studying its contents!!!

;o)
(or


next comments (4 pages)

First, confirm that you are human by entering the code you see..

(if you find the code difficult to decipher, click it for a new one!)


gd verification image

 

Welcome to corz.org!

I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!