AUBBC

 view release on metacpan or  search on metacpan

AUBBC.pm  view on Meta::CPAN

   : return '';
 }
}

sub new {
warn 'CREATING AUBBC '.$VERSION if $DEBUG_AUBBC;
 if ($MEMOIZE && ! $do_f[7]) {
  $do_f[7] = 1;
  eval 'use Memoize' if ! defined $Memoize::VERSION;
  unless ($@ || ! defined $Memoize::VERSION) {
   Memoize::memoize('AUBBC::settings');
   Memoize::memoize('AUBBC::smiley_hash');
   Memoize::memoize('AUBBC::add_build_tag');
   Memoize::memoize('AUBBC::do_all_ubbc');
   Memoize::memoize('AUBBC::script_escape');
   Memoize::memoize('AUBBC::html_to_text');
  }
   $aubbc_error .= $@."\n" if $@;
 }
return bless {};
}

sub DESTROY {
warn 'DESTROY AUBBC '.$VERSION if $DEBUG_AUBBC;
}

sub settings_prep {
$AUBBC{href_target}  = $AUBBC{href_target} ? ' target="_blank"' : '';
$AUBBC{image_wrap}   = $AUBBC{image_wrap} ? ' ' : '';
$AUBBC{image_border} = $AUBBC{image_border} ? '1' : '0';
$AUBBC{html_type}    = $AUBBC{html_type} eq 'xhtml' || $AUBBC{html_type} eq ' /' ? ' /' : '';
}

sub settings {
 my ($self,%s_hash) = @_;
  foreach (keys %s_hash) {
   if ('highlight_function' eq $_) {
    $AUBBC{highlight} = 0;
    $s_hash{$_} = check_subroutine($s_hash{$_},'');
    $AUBBC{highlight_function} = $s_hash{$_} unless ! $s_hash{$_};
   } else {
    $AUBBC{$_} = $s_hash{$_};
   }
  }
 &settings_prep;
 if ($DEBUG_AUBBC) {
  my $uabbc_settings = '';
  $uabbc_settings .= $_ . ' =>' . $AUBBC{$_} . ', ' foreach keys %AUBBC;
  warn 'AUBBC Settings Change: '.$uabbc_settings;
 }
}

sub get_setting {
 my ($self,$name) = @_;
 return $AUBBC{$name} if exists $AUBBC{$name};
}

sub code_highlight {
 my $txt = shift;
 warn 'ENTER code_highlight' if $DEBUG_AUBBC;
 $txt =~ s/:/:/g;
 $txt =~ s/\[/[/g;
 $txt =~ s/\]/]/g;

AUBBC.pm  view on Meta::CPAN

if (returner) { window.location='mailto:'+returner; }
}

function MyCodePrint (input) {
 if (input && document.getElementById(input)) {
  var TheCode = document.getElementById(input).innerHTML;
  TheCode = TheCode.replace(/<([^br<]+|\/?[puib])>/ig, "");
  codewin = window.open("", input, "width=800,height=600,resizable=yes,menubar=yes,scrollbars=yes");
  top.codewin.document.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"+
"<html>\n<head>\n<title>MyCodePrint</title>\n"+
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"+
"</head>\n<body>\n<code>"+TheCode+"</code>\n</body>\n</html>\n");
  top.codewin.document.close();
 }
}
JS
exit(0);
}

sub do_build_tag {
 warn 'ENTER do_build_tag' if $DEBUG_AUBBC;

AUBBC.pm  view on Meta::CPAN

http://search.cpan.org/~sflex/

http://aubbc.googlecode.com/

Development Notes: Highlighting functions list and tags/commands for more
language highlighters. Ideas make some new tags like [perl] or have a command in the code
tag like [code]perl:print 'perl';[/code] with a default highlighting method if
a command was not used. Then highlighting of many types of code could be allowed
even markup like HTML.

Notes: This code has a lot of settings and works good
with most default settings see the POD and example files
in the archive for usage.

=head1 NAME

AUBBC

=head1 SYNOPSIS

  use AUBBC;
  my $aubbc = AUBBC->new();

AUBBC.pm  view on Meta::CPAN

4) High Speed Parser

5) Assign security levels for links, images, build and code tags.

6) Protection for emails to hide them from harvesters.

7) Code download for code tags

8) Perl code highlighter in the code tags

9) Fully customizable settings.

The advantage of using this BBcode is to have the piece of mind of using a secure program,
to restrict the usage of HTML/XHTML elements and to make formatting of posts easy to people that have no HTML/XHTML skill.
Most sites that use these tags show a list of them and/or easy way to insert the tags to the form field by the user.

The [c] or code tags can highlight Perl code, highlighting the Perl code with CSS in HTML/XHTML,
and in the examples folder the tag_list.cgi file has a CSS code you could work from and now a setting to change to a costume highlighter function.
This module addresses many security issues the BBcode tags may have mainly cross site script also known as XSS.
Each message is escaped before it gets returned if script_escape is Enabled and checked for many types of security problems before that tag converts to HTML/XHTML.
The script_escape setting and method also converts the &#39; sign so the text can be stored in a SQL back-end.
Most of the free web portals use the &#124; sign as the delimiter for the flat file database, the script_escape setting and method also converts that sign so the structure of the database is retained.

Allows easy conversion to HTML and XHTML, existing tags will convert to the HTML type set.

If there isn't a popular tag available this module provides a method to "Build your own tags" custom tags can help link to parts of the current web page, other web pages and add other HTML elements.


=cut

AUBBC.pod  view on Meta::CPAN

4) High Speed Parser

5) Assign security levels for links, images, build and code tags.

6) Protection for emails to hide them from harvesters.

7) Code download for code tags

8) Perl code highlighter in the code tags

9) Fully customizable settings.

The advantage of using this BBcode is to have the piece of mind of using a secure program,
to restrict the usage of HTML/XHTML elements and to make formatting of posts easy to people that have no HTML/XHTML skill.
Most sites that use these tags show a list of them and/or easy way to insert the tags to the form field by the user.

The [c] or code tags can highlight Perl code, highlighting the Perl code with CSS in HTML/XHTML,
and in the examples folder the tag_list.cgi file has a CSS code you could work from and now a setting to change to a costume highlighter function.
This module addresses many security issues the BBcode tags may have mainly cross site script also known as XSS.
Each message is escaped before it gets returned if script_escape is Enabled and checked for many types of security problems before that tag converts to HTML/XHTML.
The script_escape setting and method also converts the &#39; sign so the text can be stored in a SQL back-end.
Most of the free web portals use the &#124; sign as the delimiter for the flat file database, the script_escape setting and method also converts that sign so the structure of the database is retained.

Allows easy conversion to HTML and XHTML, existing tags will convert to the HTML type set.

If there isn't a popular tag available this module provides a method to "Build your own tags" custom tags can help link to parts of the current web page, other web pages and add other HTML elements.

=head1 Security

Security advice to ensure the proper usage of this module.

=head2 Database Manipulation

The default settings of AUBBC.pm is not good for most forums, blogs, wiki's and bulletin boards
because by default AUBBC should work and be secure. The other reason is these programs will want some
of the user input editable and portable.

For editing and portability purposes you would want to retain the tags or user input as they typed it,
but always use the script_escape before saving to a back-end. This will allow you to change the settings
of AUBBC on the fly so the tags remain portable to setting changes.
The script_escape filter is vital to security for many reasons and provides a standard format for other
methods of AUBBC. There is a file in the examples folder called Database_Manipulation.pm that try's to explain what settings
to change and how to stay safe.

=head2 Mixing HTML and BBcode

Since the script_escape method will disable HTML and JavaScript, I came up with a way
to mix the two. The recommended use of mixing is for Administrator's of the program only,
because giving anyone the ability to post unfiltered codes is just wrong.

The mixing method is good for themes, information pages and wiki's just to name a few.

AUBBC.pod  view on Meta::CPAN


When adding a custom tag you will have to remember that the methods for building
custom tags try's to secure the tags. But it can not be 100% secure without
the developer of the tag knowing if and what security issues the new tag may have.

The adding method restricts characters from being used in some variables of
the tags, like name and pattern.

See the other "Build your own tags" for usage

=head2 XSS protection and settings

The script_escape filter will disable XSS so the text of the code can be seen in
HTML/XHTML and the XSS code will not work in anyway.
Some parts use standard requirements allowing only these linking path formats:

 protocal://location/web/path/or/file
 /local/web/path/or/file

There are some uncontrollable security issues with allowing images [img] and link [url] auto-link tags,
you can disable [img] tags by setting "no_img => 1," to 1 as shown.
Security issues with the [url] and auto-link tags is not as bad since you have to click it to
get to the risky web site, unlike an image loading.

=head2 FYI

XHTML has better JavaScript security standards then HTML.
Developers can also use cookies with "httponly" flags to disable JavaScript from
reading that cookie, but the browsers must support it.
XSS, browser hijacking and other security risks can change by settings, browser vendors and program versions.

=head1 Tag Security Access

New to v4.05. Assign security levels for links, images, build and code tags.
Default settings allows all tags to be seen so there would be no changes needed
if you just wanted the latest version and not use this method yet.

This method works with your current authentication and will be explained more later.

Note: The smilies is not controled by this security.

=head2 User Security Levels

Default security levels are from low to high!!!

        # The array numbers >>:    0        1         2             3
        $aubbc->security_levels('Guest', 'User', 'Moderator','Administrator')

1) The security levels array needs to have the security levels from low to high in it!!

2) The names must be spelled the same as the name passed to method user_level();

3) Security access is determined by low to high numbers and with the default Guest
will be number/level 0 in the array. if the links was set for User
the links level will have to be 1 = User making any lower level unable to
see any bbcode links but, the Administrator would still see all.

=head2 Tag Security Levels

To change the security level of links, images and code use this method this way:

        $aubbc->tag_security(
                code         => { level => 0, text => 'register to see this', },
                img          => { level => 0, text => 'register to see this', },

AUBBC.pod  view on Meta::CPAN


For the build tags leaving the variables blank will default level to 0 and
error to the $AUBBC::BAD_MESSAGE string.

=head2 User Access

This method receives the current users security level name from the web application.

        $aubbc->user_level('Administrator');

If you are using the tag security you will want to set the user_level after the user
was authenticated by the web application and before do_all_ubbc is used.

=head1 Settings

These settings effect a large part of what the do_all_ubbc method can do and what other
methods can do in do_all_ubbc. some settings are used in many methods

=head2 $aubbc->settings();

This is the method to change them when needed.

     $aubbc->settings(
        aubbc => 1,
        utf => 1,
        smileys => 1,
        highlight => 1,
        # est.....
      );

=head2 aubbc

Enable or Disable Main AUBBC Tags Default 1 is Enabled, 0 is Disable.

AUBBC.pod  view on Meta::CPAN


=head2 highlight_function

This can replace the highlighter of AUBBC with a custome one

must provide the text name of the pre-defined subroutine that receives the code
tags text and returns the highlighted text.

=head2 no_bypass

Enable or Disable User Tags for bypassing hole tag sets Default 0 is Disable, 1 is Enabled.
Bypass tag must be at the very beginning of the message!!!!
Must also be in the order of the "Bypass Tag list:" but not on a new line \n
and if #none is used the other bypass tags will not be removed.

Bypass Tag list:

        #none
        #noaubbc
        #nobuild
        #noutf

AUBBC.pod  view on Meta::CPAN

 smilies must be in /smilies folder

the images_url link must have the /smilies folder in it and not point directly to /smilies.

=head2 html_type

Default is 'html' and the only other support is 'xhtml'

=head2 fix_amp

Default is 1 Enabled and the only other setting is 0 to Disable.
This setting finds all the & that need to covert to the amp; html code name
so the w3c xhtml validation checks ok.

=head2 line_break

Enable line_break "<br>\n" Default 1 , 2 is for the "<br>" older style
that has no new line, 0 is Disable.

This will turn any new line \n to the HTML line break <br>\n or <br> by the script_escape method and the other way around
with the html_to_text method.

AUBBC.pod  view on Meta::CPAN


 code_extra => '<div style="clear: left"> </div>',

=head2 code_download

Default is '^Download above code^' this message will
be the links name. the link will open a JavaScript popup window and write the
code in it to be copyed or printed. A new JavaScript function was
added to the js_print method called MyCodePrint.

To turn off set this to ''

example:

 code_download => 'Click here to get above code.',

 code_download => '',
 
=head2 href_class

Default is '' and this allows a custom class, style and/or JavaScript to be used in the [url] tags.

AUBBC.pod  view on Meta::CPAN

  quote_extra => 'QUOTES AND SAYINGS DISPLAYED ON THIS BLOG ARE NOT WRITTEN BY THE AUTHOR OF THE BLOG.',
  quote_extra => '<div style="clear: left"> </div>',

=head2 script_escape

This will turn on or off the sanitizer/escape security for the hole message.

Default is 1 on and 0 for Disable.

Notes: 1)The code highlighter works best with an escaped character format like the
script_escape => 1 setting can provide.

2) If this setting is disabled and a character escaping method or security filter is not used
can result is a security compromise of the AUBBC tags.

3) if Disabled the method "$message = $aubbc->script_escape($message);" can be used on the message as needed before do_all_ubbc() is called.


=head2 protect_email

Default is 1 and other possible values are (0, 2, 3, 4).

Can add a protection to hide emails in the [email] tag from email harvesters.

AUBBC.pod  view on Meta::CPAN



        2 - Javascript and unicode type protection.


        3 - Javascript and unicode type protection.


        4 - Javascript encryption

The settings 2, 3 and 4 require the JavaScript function in the js_print method of
this module. js_print can be used directly and it will print out the proper file
headers for a browser to know its a JavaScript file.

=head2 email_message

When the protect_email setting is 2, 3 or 4 it will display this message as the link name.
Default message is '&#67;&#111;&#110;&#116;&#97;&#99;&#116;&#32;&#69;&#109;&#97;&#105;&#108;'
and that say's 'Contact Email'.

=head2 highlight_class#

This is for using your own class or font color for the code highlighter.

example:

        highlight_class1 => ' class="highlightclass1"',

AUBBC.pod  view on Meta::CPAN

highlight_class6 = Operator, Function and other Name's

highlight_class7 = Variables

highlight_class8 = defining subroutine

highlight_class9 = using subroutine

=head1 Smilies Settings

These are the settings for using custom smilies.

Note: There are no Built-in smilies.

=head2 $aubbc->smiley_hash();

This is how you import your custom smilies hash.

example:

  use AUBBC;
  my $aubbc = AUBBC->new();
  my %smiley = (lol => 'lol.gif');
  $aubbc->smiley_hash(%smiley);

The way you use this smiley is [lol]

Must have the images_url set to the proper location.

images_url/smilies/lol.gif

=head1 Build your own tags

These are the settings and methods for using custom tags.

=head2 $aubbc->add_build_tag(name=>'stuff', pattern=>'stuff' , type=>'stuff', function=>'stuff',...);

name - will be the tags name and is limited to a-z 0-9 - _

pattern - limited to 'all' or 'l,n,-,:,_,s'

    'all' = anything but [ or ]
    'l' = 'a-z'
    'n' = '0-9'
    's' = ' '
    '-' = '-'
    ':' = ':'
    '_' = '_'

type - 1 is style [name://pattern], 2 is style [name]pattern[/name], 3 is style [name],
the next setting for type the function will not be used to run Perl subroutines and
will replace the text with what text is defined in the function setting, the setting is
type 4 this will use style [name] but will work different then the other built settings
see function below on how type 4 works

function - a pre-defined subroutine that receives the matched pattern, tag name and returns what you want,
unless type is set to 4 then it will replace the tag with what text is in the function.

   Note: if the function returns undefined, '' or 0 the tag will not be changed.

level - the array number of the security level

error - the text or HTML to show if user has no access

        Note: For the build tags leaving the variables blank will default level to 0 and
        error to the $AUBBC::BAD_MESSAGE string.

AUBBC.pod  view on Meta::CPAN

1) Remove a single built tag: $aubbc->remove_build_tag($name);

2) Remove all built tags: $aubbc->remove_build_tag('', 1);

=head1 Error Message

=head2 $AUBBC::BAD_MESSAGE

Default message is 'Unathorized', this message is used when the code finds bad characters in [email] or [img] tags.

Usage of this setting:

  use AUBBC;
  $AUBBC::BAD_MESSAGE = 'Unauthorized use of characters or pattern in this tag.';
  # est...

=head2 $aubbc->aubbc_error();

There are two errors for add_build_tag that would die if the wrong input was given
when adding a build tag. The error message will now be stored in this method during
the instance and any new tag that had an error will not be processed.

AUBBC.pod  view on Meta::CPAN

Usage:

        $aubbc->aubbc_error('Insert Your Error'); # Add an error

        print $aubbc->aubbc_error();

        die $aubbc->aubbc_error() if $aubbc->aubbc_error();

=head1 Memoize

This setting can turn AUBBC's usage of Memoize on or off.

=head2 $AUBBC::MEMOIZE

Default setting 1 will check if it needs to load Memoize, if loaded then load the sub's that need the speed.

Setting 0 will not use Memoize.

Usage of this setting:

  use Memoize;
  # do other stuff...
  
  use AUBBC;
  
  # AUBBC will detect that Memoize was loaded
  # and just load the sub's that need the speed.
  my $aubbc = AUBBC->new();
  
  # est...

=head1 Debug

The Debug setting will send a lot of messages to warn and is not recommended to leave on all the time.

=head2 $AUBBC::DEBUG_AUBBC

Default is '' off, and Enabled is 1.

Usage of this setting:

  use AUBBC;
  $AUBBC::DEBUG_AUBBC = 1;
  # est...

=head1 Version

Returns the current version of the module.

=head2 $aubbc->version();

AUBBC.pod  view on Meta::CPAN


Addition - New Object method aubbc_error . Developers can now controle if or when
to handle errors, see the POD 'Error Message' for usage.

Fixed - All built-in tags only convert balanced tags so no unbalanced HTML can
be produced

Fixed - Bug in code_highlight a highlight regex needed to be changed after
version 4.01 to support the Parser style.

Improvement - Small restructure of add_build_tag and change the 'all' setting
of 'pattern' to allow more.

v4.02 - 11/28/2010

Fixed - The element ID for the code download started at 1 for every instance this
will force the browser to take priority to load the first ID it reads. The fix
starts the counter at 'time.$$.000' to try to produce a more unique ID for each
instance.

Fixed - under the code tag in do_ubbc line " $do_f[8] = '' if $do_f[8]; "

AUBBC.pod  view on Meta::CPAN


Addition - Perl subroutine highlighting for the code tag highlighter. Had a
problem making this till this version because a HTML code name can look like
&TheName; and a Perl subroutine looked the same till ; got converted.

Addition - AUBBC::make_image($align,$src,$width,$height,$alt) this is useful enough
to mention once.

v4.00 - 11/02/2010

Addition - New feature to the code tags aubbc_setting code_download.
the default setting for code_download is '^Download above code^' this message will
be the links name. the link will open a JavaScript pop-up window and write the
code in it to be copied or printed to a printer. A new JavaScript function was
added to the js_print method called MyCodePrint. JavaScript makes this feature
portable and dynamic. the link for code_download is added after the code_extra
setting so a disclaimer can be added before the code_download link

Addition - $AUBBC::MEMOIZE This setting can turn AUBBC's usage of Memoize on or off.
Default setting 1 will check if it needs to load Memoize, if loaded then load the sub's that need the speed.
Setting 0 will not use Memoize.

Addition - AUBBC::make_link($link,$name,$javascript,$target) this is useful enough
to mention once.

Improvement - After lots of testing I have removed all /o in the regex. One main
reason is Memoize provides enough speed.

v3.13 - 09/30/2010

Addition - do_ubbc New built-in tag [list][*=1]... [*]... [/list], This will
follow XHTML or HTML Transitional element style and XHTML or HTML Strict will not
support the elements that tag [*=1] in the [list] will produce
(use the other enumerated List Block tags for XHTML or HTML Strict).

Addition - do_ubbc New built-in tag [em]Hello[/em]

Addition - New value for setting line_break 2 for old <br style. This effects script_escape.

Addition - This module now uses Memoize for a massive speed improvement.
If you thought it was fast before, I hope your sitting down when you bench this version. LOL

Addition - added setting highlight_function to replace the highlighting method
of AUBBC with a costume one.

Fixed - in do_ubbc the line breaks was invalidating HTML for List Block elements

Improvement - in do_all_ubbc changed defining $msg each time. there could have
been a bug in past versions if an undefined variable was used after a defined message was
converted. was going to allow do_all_ubbc to pass the last message but decided
other people may see that as a bug.

Improvement - in do_all_ubbc moved if $do_flag[4] for no_bypass to a better spot

AUBBC.pod  view on Meta::CPAN

Improvement - Massive speed improvement to the hole module and no features lost.
changed new for faster loading, the module uses vars for some variables,
re-spaced the hole code.

v2.10 - 08/31/2010 11:17:13

Addition - adding type 4 to add_build_tag this will use style 3 but will work
different then the other built functions. Type 4 will print the text defined in
function and not point to a defined Perl subroutine.

Addition - added line_break setting to have control over the script_escape and
html_to_text methods converting html line break <br> and new line \n

Addition - added fix_amp this setting finds all the & that need to covert to the amp; html code name
so the w3c xhtml validation checks ok.

Addition - added no_img this setting will allow some control for using [img] tags
for security reasons

Fixed - bug in settings_prep when a setting gets changed html_type could change

Fixed - Better support for XHTML 1.0 Strict for some tags having issues in do_ubbc

Fixed - in do_ubbc the [url] tag produces a bug if a link is used as a name
the fix converts the period and/or colon of the name so its not seen as a new
link.

Improvement - in do_unicode removed then changed the two regexs to do a 3 in 1 filter.

Improvement - in html_to_text added a code to fix a <br> bug if ppl use html or xhtml line break.

AUBBC.pod  view on Meta::CPAN

Removed - In script_escape removed the \cM regex, it is very rare that anyone will need
it so it wont be missed.


v2.0 - 10/07/2008 13:52:11

Fixed single tag [name] for build tags

Changed the regex in plain URL's

Removed bad patter setting and now using a more standard way to detect bad image tags

Fixed dynamic view in XHTML for the protect email method.

Added js_print method which will print out the javascript needed for the new protect email method

Added values for the code highlighter so it can support CSS classes

Added highlighting of variables and changed 2 quote regex to allow multi line quotes

and a few other things that make this 2.0

AUBBC.pod  view on Meta::CPAN

v1.10 - 09/02/2008 09:49:46

Added two more tags [big]..[/big] and [small]..[/small].

Removed utf tag style [ux23] and [u://0931] to make more tag names available.

Changed add_build_tag() to use hash variable, see "Build your own tags" for the new style.

Changed the way functions should work for built tags, the custom function for built tags will receive the tag name and data of the tag. This is so one function can handle many tags.

Removed other site tags and setting other_sites_pattern, an example of them are in "Build your own tags"

Removed [time] tag, example in "Build your own tags".

Email now allows names with & sign

Now every message that is passed to do_all_ubbc() gets escaped before being returned if script_escape is Enabled.

All tags in %AUBBC_TAGS will only convert if lowercase.

"new" now uses the most standard referenced object method.

AUBBC.pod  view on Meta::CPAN

http://search.cpan.org/~sflex/

http://aubbc.googlecode.com/

Development Notes: Highlighting functions list and tags/commands for more
language highlighters. Ideas make some new tags like [perl] or have a command in the code
tag like [code]perl:$some ='perl';[/code] with a default highlighting method if
a command was not used. Then highlighting of many types of code could be allowed
even markup like HTML.

Notes: This code has a lot of settings and works good
with most default settings see the POD and example files
in the archive for usage.

=cut

CHANGES  view on Meta::CPAN


Addition - New Object method aubbc_error . Developers can now controle if or when
to handle errors, see the POD 'Error Message' for usage.

Fixed - All built-in tags only convert balanced tags so no unbalanced HTML can
be produced

Fixed - Bug in code_highlight a highlight regex needed to be changed after
version 4.01 to support the Parser style.

Improvement - Small restructure of add_build_tag and change the 'all' setting
of 'pattern' to allow more.

v4.02 - 11/28/2010

Fixed - The element ID for the code download started at 1 for every instance this
will force the browser to take priority to load the first ID it reads. The fix
starts the counter at 'time.$$.000' to try to produce a more unique ID for each
instance.

Fixed - under the code tag in do_ubbc line " $do_f[8] = '' if $do_f[8]; "

CHANGES  view on Meta::CPAN


Addition - Perl subroutine highlighting for the code tag highlighter. Had a
problem making this till this version because a HTML code name can look like
&TheName; and a Perl subroutine looked the same till ; got converted.

Addition - AUBBC::make_image($align,$src,$width,$height,$alt) this is useful enough
to mention once.

v4.00 - 11/02/2010

Addition - New feature to the code tags aubbc_setting code_download.
the default setting for code_download is '^Download above code^' this message will
be the links name. the link will open a JavaScript pop-up window and write the
code in it to be copied or printed to a printer. A new JavaScript function was
added to the js_print method called MyCodePrint. JavaScript makes this feature
portable and dynamic. the link for code_download is added after the code_extra
setting so a disclaimer can be added before the code_download link

Addition - $AUBBC::MEMOIZE This setting can turn AUBBC's usage of Memoize on or off.
Default setting 1 will check if it needs to load Memoize, if loaded then load the sub's that need the speed.
Setting 0 will not use Memoize.

Addition - AUBBC::make_link($link,$name,$javascript,$target) this is useful enough
to mention once.

Improvement - After lots of testing I have removed all /o in the regex. One main
reason is Memoize provides enough speed.

v3.13 - 09/30/2010

Addition - do_ubbc New built-in tag [list][*=1]... [*]... [/list], This will
follow XHTML or HTML Transitional element style and XHTML or HTML Strict will not
support the elements that tag [*=1] in the [list] will produce
(use the other enumerated List Block tags for XHTML or HTML Strict).

Addition - do_ubbc New built-in tag [em]Hello[/em]

Addition - New value for setting line_break 2 for old <br style. This effects script_escape.

Addition - This module now uses Memoize for a massive speed improvement.
If you thought it was fast before, I hope your sitting down when you bench this version. LOL

Addition - added setting highlight_function to replace the highlighting method
of AUBBC with a costume one.

Fixed - in do_ubbc the line breaks was invalidating HTML for List Block elements

Improvement - in do_all_ubbc changed defining $msg each time. there could have
been a bug in past versions if an undefined variable was used after a defined message was
converted. was going to allow do_all_ubbc to pass the last message but decided
other people may see that as a bug.

Improvement - in do_all_ubbc moved if $do_flag[4] for no_bypass to a better spot

CHANGES  view on Meta::CPAN

Improvement - Massive speed improvement to the hole module and no features lost.
changed new for faster loading, the module uses vars for some variables,
re-spaced the hole code.

v2.10 - 08/31/2010 11:17:13

Addition - adding type 4 to add_build_tag this will use style 3 but will work
different then the other built functions. Type 4 will print the text defined in
function and not point to a defined Perl subroutine.

Addition - added line_break setting to have control over the script_escape and
html_to_text methods converting html line break <br> and new line \n

Addition - added fix_amp this setting finds all the & that need to covert to the amp; html code name
so the w3c xhtml validation checks ok.

Addition - added no_img this setting will allow some control for using [img] tags
for security reasons

Fixed - bug in settings_prep when a setting gets changed html_type could change

Fixed - Better support for XHTML 1.0 Strict for some tags having issues in do_ubbc

Fixed - in do_ubbc the [url] tag produces a bug if a link is used as a name
the fix converts the period and/or colon of the name so its not seen as a new
link.

Improvement - in do_unicode removed then changed the two regexs to do a 3 in 1 filter.

Improvement - in html_to_text added a code to fix a <br> bug if ppl use html or xhtml line break.

CHANGES  view on Meta::CPAN

Removed - In script_escape removed the \cM regex, it is very rare that anyone will need
it so it wont be missed.


v2.0 - 10/07/2008 13:52:11

Fixed single tag [name] for build tags

Changed the regex in plain URL's

Removed bad patter setting and now using a more standard way to detect bad image tags

Fixed dynamic view in XHTML for the protect email method.

Added js_print method which will print out the javascript needed for the new protect email method

Added values for the code highlighter so it can support CSS classes

Added highlighting of variables and changed 2 quote regex to allow multi line quotes

and a few other things that make this 2.0

CHANGES  view on Meta::CPAN

v1.10 - 09/02/2008 09:49:46

Added two more tags [big]..[/big] and [small]..[/small].

Removed utf tag style [ux23] and [u://0931] to make more tag names available.

Changed add_build_tag() to use hash variable, see "Build your own tags" for the new style.

Changed the way functions should work for built tags, the custom function for built tags will receive the tag name and data of the tag. This is so one function can handle many tags.

Removed other site tags and setting other_sites_pattern, an example of them are in "Build your own tags"

Removed [time] tag, example in "Build your own tags".

Email now allows names with & sign

Now every message that is passed to do_all_ubbc() gets escaped before being returned if script_escape is Enabled.

All tags in %AUBBC_TAGS will only convert if lowercase.

"new" now uses the most standard referenced object method.

README  view on Meta::CPAN

4) High Speed Parser

5) Assign security levels for links, images, build and code tags.

6) Protection for emails to hide them from harvesters.

7) Code download for code tags

8) Perl code highlighter in the code tags

9) Fully customizable settings.

The advantage of using this BBcode is to have the piece of mind of using a secure program,
to restrict the usage of HTML/XHTML elements and to make formatting of posts easy to people that have no HTML/XHTML skill.
Most sites that use these tags show a list of them and/or easy way to insert the tags to the form field by the user.

The [c] or code tags can highlight Perl code, highlighting the Perl code with CSS in HTML/XHTML,
and in the examples folder the tag_list.cgi file has a CSS code you could work from and now a setting to change to a costume highlighter function.
This module addresses many security issues the BBcode tags may have mainly cross site script also known as XSS.
Each message is escaped before it gets returned if script_escape is Enabled and checked for many types of security problems before that tag converts to HTML/XHTML.
The script_escape setting and method also converts the &#39; sign so the text can be stored in a SQL back-end.
Most of the free web portals use the &#124; sign as the delimiter for the flat file database, the script_escape setting and method also converts that sign so the structure of the database is retained.

Allows easy conversion to HTML and XHTML, existing tags will convert to the HTML type set.

If there isn't a popular tag available this module provides a method to "Build your own tags" custom tags can help link to parts of the current web page, other web pages and add other HTML elements.

=head1 Security

Security advice to ensure the proper usage of this module.

=head2 Database Manipulation

The default settings of AUBBC.pm is not good for most forums, blogs, wiki's and bulletin boards
because by default AUBBC should work and be secure. The other reason is these programs will want some
of the user input editable and portable.

For editing and portability purposes you would want to retain the tags or user input as they typed it,
but always use the script_escape before saving to a back-end. This will allow you to change the settings
of AUBBC on the fly so the tags remain portable to setting changes.
The script_escape filter is vital to security for many reasons and provides a standard format for other
methods of AUBBC. There is a file in the examples folder called Database_Manipulation.pm that try's to explain what settings
to change and how to stay safe.

=head2 Mixing HTML and BBcode

Since the script_escape method will disable HTML and JavaScript, I came up with a way
to mix the two. The recommended use of mixing is for Administrator's of the program only,
because giving anyone the ability to post unfiltered codes is just wrong.

The mixing method is good for themes, information pages and wiki's just to name a few.

README  view on Meta::CPAN


When adding a custom tag you will have to remember that the methods for building
custom tags try's to secure the tags. But it can not be 100% secure without
the developer of the tag knowing if and what security issues the new tag may have.

The adding method restricts characters from being used in some variables of
the tags, like name and pattern.

See the other "Build your own tags" for usage

=head2 XSS protection and settings

The script_escape filter will disable XSS so the text of the code can be seen in
HTML/XHTML and the XSS code will not work in anyway.
Some parts use standard requirements allowing only these linking path formats:

 protocal://location/web/path/or/file
 /local/web/path/or/file

There are some uncontrollable security issues with allowing images [img] and link [url] auto-link tags,
you can disable [img] tags by setting "no_img => 1," to 1 as shown.
Security issues with the [url] and auto-link tags is not as bad since you have to click it to
get to the risky web site, unlike an image loading.

=head2 FYI

XHTML has better JavaScript security standards then HTML.
Developers can also use cookies with "httponly" flags to disable JavaScript from
reading that cookie, but the browsers must support it.
XSS, browser hijacking and other security risks can change by settings, browser vendors and program versions.

=head1 Tag Security Access

New to v4.05. Assign security levels for links, images, build and code tags.
Default settings allows all tags to be seen so there would be no changes needed
if you just wanted the latest version and not use this method yet.

This method works with your current authentication and will be explained more later.

Note: The smilies is not controled by this security.

=head2 User Security Levels

Default security levels are from low to high!!!

        # The array numbers >>:    0        1         2             3
        $aubbc->security_levels('Guest', 'User', 'Moderator','Administrator')

1) The security levels array needs to have the security levels from low to high in it!!

2) The names must be spelled the same as the name passed to method user_level();

3) Security access is determined by low to high numbers and with the default Guest
will be number/level 0 in the array. if the links was set for User
the links level will have to be 1 = User making any lower level unable to
see any bbcode links but, the Administrator would still see all.

=head2 Tag Security Levels

To change the security level of links, images and code use this method this way:

        $aubbc->tag_security(
                code         => { level => 0, text => 'register to see this', },
                img          => { level => 0, text => 'register to see this', },

README  view on Meta::CPAN


For the build tags leaving the variables blank will default level to 0 and
error to the $AUBBC::BAD_MESSAGE string.

=head2 User Access

This method receives the current users security level name from the web application.

        $aubbc->user_level('Administrator');

If you are using the tag security you will want to set the user_level after the user
was authenticated by the web application and before do_all_ubbc is used.

=head1 Settings

These settings effect a large part of what the do_all_ubbc method can do and what other
methods can do in do_all_ubbc. some settings are used in many methods

=head2 $aubbc->settings();

This is the method to change them when needed.

     $aubbc->settings(
        aubbc => 1,
        utf => 1,
        smileys => 1,
        highlight => 1,
        # est.....
      );

=head2 aubbc

Enable or Disable Main AUBBC Tags Default 1 is Enabled, 0 is Disable.

README  view on Meta::CPAN


=head2 highlight_function

This can replace the highlighter of AUBBC with a custome one

must provide the text name of the pre-defined subroutine that receives the code
tags text and returns the highlighted text.

=head2 no_bypass

Enable or Disable User Tags for bypassing hole tag sets Default 0 is Disable, 1 is Enabled.
Bypass tag must be at the very beginning of the message!!!!
Must also be in the order of the "Bypass Tag list:" but not on a new line \n
and if #none is used the other bypass tags will not be removed.

Bypass Tag list:

        #none
        #noaubbc
        #nobuild
        #noutf

README  view on Meta::CPAN

 smilies must be in /smilies folder

the images_url link must have the /smilies folder in it and not point directly to /smilies.

=head2 html_type

Default is 'html' and the only other support is 'xhtml'

=head2 fix_amp

Default is 1 Enabled and the only other setting is 0 to Disable.
This setting finds all the & that need to covert to the amp; html code name
so the w3c xhtml validation checks ok.

=head2 line_break

Enable line_break "<br>\n" Default 1 , 2 is for the "<br>" older style
that has no new line, 0 is Disable.

This will turn any new line \n to the HTML line break <br>\n or <br> by the script_escape method and the other way around
with the html_to_text method.

README  view on Meta::CPAN


 code_extra => '<div style="clear: left"> </div>',

=head2 code_download

Default is '^Download above code^' this message will
be the links name. the link will open a JavaScript popup window and write the
code in it to be copyed or printed. A new JavaScript function was
added to the js_print method called MyCodePrint.

To turn off set this to ''

example:

 code_download => 'Click here to get above code.',

 code_download => '',

=head2 href_class

Default is '' and this allows a custom class, style and/or JavaScript to be used in the [url] tags.

README  view on Meta::CPAN

  quote_extra => 'QUOTES AND SAYINGS DISPLAYED ON THIS BLOG ARE NOT WRITTEN BY THE AUTHOR OF THE BLOG.',
  quote_extra => '<div style="clear: left"> </div>',

=head2 script_escape

This will turn on or off the sanitizer/escape security for the hole message.

Default is 1 on and 0 for Disable.

Notes: 1)The code highlighter works best with an escaped character format like the
script_escape => 1 setting can provide.

2) If this setting is disabled and a character escaping method or security filter is not used
can result is a security compromise of the AUBBC tags.

3) if Disabled the method "$message = $aubbc->script_escape($message);" can be used on the message as needed before do_all_ubbc() is called.


=head2 protect_email

Default is 1 and other possible values are (0, 2, 3, 4).

Can add a protection to hide emails in the [email] tag from email harvesters.

README  view on Meta::CPAN



        2 - Javascript and unicode type protection.


        3 - Javascript and unicode type protection.


        4 - Javascript encryption

The settings 2, 3 and 4 require the JavaScript function in the js_print method of
this module. js_print can be used directly and it will print out the proper file
headers for a browser to know its a JavaScript file.

=head2 email_message

When the protect_email setting is 2, 3 or 4 it will display this message as the link name.
Default message is '&#67;&#111;&#110;&#116;&#97;&#99;&#116;&#32;&#69;&#109;&#97;&#105;&#108;'
and that say's 'Contact Email'.

=head2 highlight_class#

This is for using your own class or font color for the code highlighter.

example:

        highlight_class1 => ' class="highlightclass1"',

README  view on Meta::CPAN

highlight_class6 = Operator, Function and other Name's

highlight_class7 = Variables

highlight_class8 = defining subroutine

highlight_class9 = using subroutine

=head1 Smilies Settings

These are the settings for using custom smilies.

Note: There are no Built-in smilies.

=head2 $aubbc->smiley_hash();

This is how you import your custom smilies hash.

example:

  use AUBBC;
  my $aubbc = AUBBC->new();
  my %smiley = (lol => 'lol.gif');
  $aubbc->smiley_hash(%smiley);

The way you use this smiley is [lol]

Must have the images_url set to the proper location.

images_url/smilies/lol.gif

=head1 Build your own tags

These are the settings and methods for using custom tags.

=head2 $aubbc->add_build_tag(name=>'stuff', pattern=>'stuff' , type=>'stuff', function=>'stuff',...);

name - will be the tags name and is limited to a-z 0-9 - _

pattern - limited to 'all' or 'l,n,-,:,_,s'

    'all' = anything but [ or ]
    'l' = 'a-z'
    'n' = '0-9'
    's' = ' '
    '-' = '-'
    ':' = ':'
    '_' = '_'

type - 1 is style [name://pattern], 2 is style [name]pattern[/name], 3 is style [name],
the next setting for type the function will not be used to run Perl subroutines and
will replace the text with what text is defined in the function setting, the setting is
type 4 this will use style [name] but will work different then the other built settings
see function below on how type 4 works

function - a pre-defined subroutine that receives the matched pattern, tag name and returns what you want,
unless type is set to 4 then it will replace the tag with what text is in the function.

   Note: if the function returns undefined, '' or 0 the tag will not be changed.

level - the array number of the security level

error - the text or HTML to show if user has no access

        Note: For the build tags leaving the variables blank will default level to 0 and
        error to the $AUBBC::BAD_MESSAGE string.

README  view on Meta::CPAN

1) Remove a single built tag: $aubbc->remove_build_tag($name);

2) Remove all built tags: $aubbc->remove_build_tag('', 1);

=head1 Error Message

=head2 $AUBBC::BAD_MESSAGE

Default message is 'Unathorized', this message is used when the code finds bad characters in [email] or [img] tags.

Usage of this setting:

  use AUBBC;
  $AUBBC::BAD_MESSAGE = 'Unauthorized use of characters or pattern in this tag.';
  # est...

=head2 $aubbc->aubbc_error();

There are two errors for add_build_tag that would die if the wrong input was given
when adding a build tag. The error message will now be stored in this method during
the instance and any new tag that had an error will not be processed.

README  view on Meta::CPAN

Usage:

        $aubbc->aubbc_error('Insert Your Error'); # Add an error

        print $aubbc->aubbc_error();

        die $aubbc->aubbc_error() if $aubbc->aubbc_error();

=head1 Memoize

This setting can turn AUBBC's usage of Memoize on or off.

=head2 $AUBBC::MEMOIZE

Default setting 1 will check if it needs to load Memoize, if loaded then load the sub's that need the speed.

Setting 0 will not use Memoize.

Usage of this setting:

  use Memoize;
  # do other stuff...

  use AUBBC;

  # AUBBC will detect that Memoize was loaded
  # and just load the sub's that need the speed.
  my $aubbc = AUBBC->new();

  # est...

=head1 Debug

The Debug setting will send a lot of messages to warn and is not recommended to leave on all the time.

=head2 $AUBBC::DEBUG_AUBBC

Default is '' off, and Enabled is 1.

Usage of this setting:

  use AUBBC;
  $AUBBC::DEBUG_AUBBC = 1;
  # est...

=head1 Version

Returns the current version of the module.

=head2 $aubbc->version();

README  view on Meta::CPAN


Addition - New Object method aubbc_error . Developers can now controle if or when
to handle errors, see the POD 'Error Message' for usage.

Fixed - All built-in tags only convert balanced tags so no unbalanced HTML can
be produced

Fixed - Bug in code_highlight a highlight regex needed to be changed after
version 4.01 to support the Parser style.

Improvement - Small restructure of add_build_tag and change the 'all' setting
of 'pattern' to allow more.

v4.02 - 11/28/2010

Fixed - The element ID for the code download started at 1 for every instance this
will force the browser to take priority to load the first ID it reads. The fix
starts the counter at 'time.$$.000' to try to produce a more unique ID for each
instance.

Fixed - under the code tag in do_ubbc line " $do_f[8] = '' if $do_f[8]; "

README  view on Meta::CPAN


Addition - Perl subroutine highlighting for the code tag highlighter. Had a
problem making this till this version because a HTML code name can look like
&TheName; and a Perl subroutine looked the same till ; got converted.

Addition - AUBBC::make_image($align,$src,$width,$height,$alt) this is useful enough
to mention once.

v4.00 - 11/02/2010

Addition - New feature to the code tags aubbc_setting code_download.
the default setting for code_download is '^Download above code^' this message will
be the links name. the link will open a JavaScript pop-up window and write the
code in it to be copied or printed to a printer. A new JavaScript function was
added to the js_print method called MyCodePrint. JavaScript makes this feature
portable and dynamic. the link for code_download is added after the code_extra
setting so a disclaimer can be added before the code_download link

Addition - $AUBBC::MEMOIZE This setting can turn AUBBC's usage of Memoize on or off.
Default setting 1 will check if it needs to load Memoize, if loaded then load the sub's that need the speed.
Setting 0 will not use Memoize.

Addition - AUBBC::make_link($link,$name,$javascript,$target) this is useful enough
to mention once.

Improvement - After lots of testing I have removed all /o in the regex. One main
reason is Memoize provides enough speed.

v3.13 - 09/30/2010

Addition - do_ubbc New built-in tag [list][*=1]... [*]... [/list], This will
follow XHTML or HTML Transitional element style and XHTML or HTML Strict will not
support the elements that tag [*=1] in the [list] will produce
(use the other enumerated List Block tags for XHTML or HTML Strict).

Addition - do_ubbc New built-in tag [em]Hello[/em]

Addition - New value for setting line_break 2 for old <br style. This effects script_escape.

Addition - This module now uses Memoize for a massive speed improvement.
If you thought it was fast before, I hope your sitting down when you bench this version. LOL

Addition - added setting highlight_function to replace the highlighting method
of AUBBC with a costume one.

Fixed - in do_ubbc the line breaks was invalidating HTML for List Block elements

Improvement - in do_all_ubbc changed defining $msg each time. there could have
been a bug in past versions if an undefined variable was used after a defined message was
converted. was going to allow do_all_ubbc to pass the last message but decided
other people may see that as a bug.

Improvement - in do_all_ubbc moved if $do_flag[4] for no_bypass to a better spot

README  view on Meta::CPAN

Improvement - Massive speed improvement to the hole module and no features lost.
changed new for faster loading, the module uses vars for some variables,
re-spaced the hole code.

v2.10 - 08/31/2010 11:17:13

Addition - adding type 4 to add_build_tag this will use style 3 but will work
different then the other built functions. Type 4 will print the text defined in
function and not point to a defined Perl subroutine.

Addition - added line_break setting to have control over the script_escape and
html_to_text methods converting html line break <br> and new line \n

Addition - added fix_amp this setting finds all the & that need to covert to the amp; html code name
so the w3c xhtml validation checks ok.

Addition - added no_img this setting will allow some control for using [img] tags
for security reasons

Fixed - bug in settings_prep when a setting gets changed html_type could change

Fixed - Better support for XHTML 1.0 Strict for some tags having issues in do_ubbc

Fixed - in do_ubbc the [url] tag produces a bug if a link is used as a name
the fix converts the period and/or colon of the name so its not seen as a new
link.

Improvement - in do_unicode removed then changed the two regexs to do a 3 in 1 filter.

Improvement - in html_to_text added a code to fix a <br> bug if ppl use html or xhtml line break.

README  view on Meta::CPAN

Removed - In script_escape removed the \cM regex, it is very rare that anyone will need
it so it wont be missed.


v2.0 - 10/07/2008 13:52:11

Fixed single tag [name] for build tags

Changed the regex in plain URL's

Removed bad patter setting and now using a more standard way to detect bad image tags

Fixed dynamic view in XHTML for the protect email method.

Added js_print method which will print out the javascript needed for the new protect email method

Added values for the code highlighter so it can support CSS classes

Added highlighting of variables and changed 2 quote regex to allow multi line quotes

and a few other things that make this 2.0

README  view on Meta::CPAN

v1.10 - 09/02/2008 09:49:46

Added two more tags [big]..[/big] and [small]..[/small].

Removed utf tag style [ux23] and [u://0931] to make more tag names available.

Changed add_build_tag() to use hash variable, see "Build your own tags" for the new style.

Changed the way functions should work for built tags, the custom function for built tags will receive the tag name and data of the tag. This is so one function can handle many tags.

Removed other site tags and setting other_sites_pattern, an example of them are in "Build your own tags"

Removed [time] tag, example in "Build your own tags".

Email now allows names with & sign

Now every message that is passed to do_all_ubbc() gets escaped before being returned if script_escape is Enabled.

All tags in %AUBBC_TAGS will only convert if lowercase.

"new" now uses the most standard referenced object method.

README  view on Meta::CPAN

http://search.cpan.org/~sflex/

http://aubbc.googlecode.com/

Development Notes: Highlighting functions list and tags/commands for more
language highlighters. Ideas make some new tags like [perl] or have a command in the code
tag like [code]perl:$some ='perl';[/code] with a default highlighting method if
a command was not used. Then highlighting of many types of code could be allowed
even markup like HTML.

Notes: This code has a lot of settings and works good
with most default settings see the POD and example files
in the archive for usage.

=cut

examples/Database_Manipulation.cgi  view on Meta::CPAN

 http://search.cpan.org/~sflex/
 
=head1 ABSTRACT

Advanced Universal Bulletin Board Code a Perl BBcode API

=head1 DESCRIPTION

This is a none working file(syntax checks ok)! It discribes one way to use this module
in projects like forums, blogs, wiki's, bulletin boards or other development.
Keep in mind Im trying to explain the settings, when to use methods to ensure
security of the module and a simple method to save user input to be
edited later.

Other settings may effect the message output also.

=cut

# Start the module
use AUBBC;
my $aubbc = new AUBBC;

# script_escape will need to be disabled in the settings method and
# this will tell the do_all_ubbc method not to use script_escape!
#
# other settings can be changed here if needed.
$aubbc->settings(
        script_escape => 0,
        );

# Build your own tags can be added, est......

# This will be the data or users input from a HTML form to save to a backend.
# The message will have some characters that would normaly brake some database
# structures, cause risky errors or be html.

my $message = <<FORM;

examples/Database_Manipulation.cgi  view on Meta::CPAN

# depending on the type of backend used.......

}

sub editing_data {
# This will be a two part subroutine. This first one will get the message from
# the backend and display the data in a HTML form to be edited lets say its
# in variable $form_data

# Since this gets into sandboxing the html_to_text method you may want
# to play with settings for other view's or can skip the form feilds sandboxing
# the option 1 for html_to_text is needed to not convert &, spaces, tab's

$form_data = $aubbc->html_to_text( $form_data );

# Now $form_data can be printed in the form feild
# When the HTML form is submitted we fictitiously sent the edited data to editing_data2
# of this file to be saved
}

sub editing_data2 {

examples/Mixing_HTML_and_BBcode.cgi  view on Meta::CPAN

 http://search.cpan.org/~sflex/

=head1 ABSTRACT

Advanced Universal Bulletin Board Code a Perl BBcode API

=head1 DESCRIPTION

This is a none working file(syntax checks ok)! It discribes one way to use this module
in projects like forums, blogs, wiki's, bulletin boards or other development.
Keep in mind Im trying to explain the settings, when to use methods to ensure
security of the module and a simple method to save user input to be
edited later.

Other settings may effect the message output also.

=cut

# Start the module
use AUBBC;
my $aubbc = new AUBBC;

# script_escape will need to be disabled in the settings method and
# this will tell the do_all_ubbc method not to use script_escape!
#
# other settings can be changed here if needed.
$aubbc->settings(
        script_escape => 0,
        );

# Build your own tags can be added, est......

# This will be the data or Administrator input from a HTML form to save to a backend.
# The message will have some BBcode mixed in HTML and a home made tage for full
# AUBBC support is <aubbc> Full AUBBC support </aubbc>

my $message = <<HTML;

examples/Mixing_HTML_and_BBcode.cgi  view on Meta::CPAN

# depending on the type of backend used.......

}

sub editing_data {
# This will be a two part subroutine. This first one will get the message from
# the backend and display the data in a HTML form to be edited lets say its
# in variable $form_data

# Since this gets into sandboxing the script_escape method you may want
# to play with settings for other view's or can skip the form feilds sandboxing
# the option 1 for script_escape is needed to not convert spaces, tab's, new lines

$form_data =~ s/(<aubbc>(?s)(.*?)<\/aubbc>)/
        my $ret = $aubbc->html_to_text( $2 );
        $ret ? '<aubbc>'.$ret."<\/aubbc>" : $1;
        /exg;
$form_data = $aubbc->script_escape( $form_data, 1 );

# Now $form_data can be printed in the form feild
# When the HTML form is submitted we fictitiously sent the edited data to editing_data2

examples/tag_list.cgi  view on Meta::CPAN

#!perl

use strict;
use warnings;
#use lib '../';
use AUBBC;
my $aubbc = AUBBC->new();

# Change some default settings
$aubbc->settings(
        protect_email => 4,
        html_type => 'xhtml',
        code_class => ' class="codepost"',
        code_extra => '<div style="clear: left"> </div>',
        quote_class => ' class="quote"',
        quote_extra => '<div style="clear: left"> </div>',
        highlight_class1 => ' class="highlightclass1"',
        highlight_class2 => ' class="highlightclass2"',
        highlight_class3 => ' class="highlightclass1"',
        highlight_class4 => ' class="highlightclass1"',

examples/tag_list.cgi  view on Meta::CPAN

 ? $aubbc->aubbc_error()
 : $aubbc->do_all_ubbc($message);

print "Content-type: text/html\n\n";
print <<HTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>AUBBC.pm Tag List</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<script type="text/javascript" src="?js_print">
</script>
<style type="text/css">
.codepost {
background-color: #ffffff;
 width: 80%;
 height: auto;
 white-space: nowrap;

test.pl  view on Meta::CPAN

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

######################### We start with some black magic to print on failure.

# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)

my ($count, $message, $setting, $aubbc, $Current_version, %msg) =
 (1, '[br][utf://#x23]', '', '', '', (1 => 'Test good ', 2 => 'Test error ',) );

BEGIN {
 $| = 1;
 print "Test's 1 to 4\n";
}

use AUBBC;
$aubbc = new AUBBC;
{
 # did it load?
 #$aubbc = ''; # main reinforce failure
 $aubbc
  ? print $msg{1} . "$count\n"
  : print $msg{2} . "$count\n";

 $aubbc->settings(html_type => 'xhtml') if $aubbc;
 $message = $aubbc->do_all_ubbc($message) if $aubbc;
 $setting = $aubbc->get_setting('html_type') if $aubbc;
 $Current_version = $aubbc->version() if $aubbc;

 $count++;
 # did it convert?
 #$message .= ']'; # reinforce failure
 $message !~ m/[\[\]\:]+/
  ? print $msg{1} . "$count\n"
  : print $msg{2} . "$count\n";
}

END {
 $count++;
 # did we get a setting?
 #$setting = 5; # reinforce failure
 $setting eq ' /'
  ? print $msg{1} . "$count\n"
  : print $msg{2} . "$count\n";

  $count++;
 # did we get the version?
 #$Current_version = 5; # reinforce failure
 $Current_version eq '4.06'
  ? print $msg{1} . "$count\n"
  : print $msg{2} . "$count\n";
}



( run in 1.391 second using v1.01-cache-2.11-cpan-49f99fa48dc )