textile / php-textile

Textile markup language parser for PHP
https://textile-lang.com
Other
216 stars 44 forks source link

fix undefined offset on strict mode #83

Closed mkdgs closed 11 years ago

mkdgs commented 12 years ago

textile code like : =.=.= (remove . between =) =.=.=.=

generate error in strict mode (undefined offset). use of array_pad to avoid that. (it's maybe also a good idea to apply array_pad on all list() in this class)

netcarver commented 12 years ago

Hello. I'm trying to reproduce this locally in my test setup. Can you show me the arguments you are using to call TextileThis() please?

mkdgs commented 12 years ago

ok ! i know why you can't reproduce that, i used error_handler and this break @ silence opérator.

require_once('classTextile.php');
ini_set('error_reporting', -1);
ini_set('display_errors', 1);
ini_set('html_errors', 1);
function error_( $number, $message, $file, $line )  {
        $error = array( 'type' => $number, 'message' => $message, 'file' => $file, 'line' => $line );
        print_r( $error );
}
set_error_handler('error_');
$txt = '
=== 
foo
==== 
';
$textile = new Textile();
echo $textile->TextileThis($txt);

sorry it's due by my developpement environement, but i think array_pad is a better practice.

netcarver commented 11 years ago

Ok, looking at this right now and removing the @ allows it to manifest clearly. I'll probably pad with '' (empty string) rather than null here.