1 anonymous Mar 31, 2006 13:58
3 pvasili Mar 31, 2006 15:27
blueyed wrote:
You can work around this problem, where I'm not sure what it's caused by, by temporarily(!) disabling the xhtml checker in /conf/_formatting.php: Set $use_html_checker = 0 there, change your blog settings and set it to 1 after that again.
About the problem: do you have any content in the "subtitle", "long description" or "notes" fields?
It might be a problem with the PHP xml_parser and the used encoding (while saving).
1) Work, thank you :)
2) About: i have first setup b2ev with English locale, and if i create new blog :(
3) may be my PHP or xml_parser?
PHP version 4.1.8
XML Support active
XML Namespace Support active
EXPAT Version 1.95.6
4 blueyed Mar 31, 2006 22:47
You are using 0.9.1, correct?
Could you please try the following?
1. in /admin/blogs.php, search for "format_to_post". It should be there six times.
From, e.g.:
$blog_notes = format_to_post( $blog_notes, 0, 0, $locales[ $blog_locale ][ 'charset' ] );
to
$blog_notes = format_to_post( $blog_notes );
2. in /b2evocore/_functions.php, search for "function format_to_post" and change it from
function format_to_post( $content, $autobr = 0, $is_comment = 0, $encoding = 'ISO-8859-1' )
to
function format_to_post( $content, $autobr = 0, $is_comment = 0, $encoding = '' )
3. In the same function, in the "if( $use_html_checker )" block, add the following:
if( empty($encoding) )
{
// TODO: use $io_charset
$encoding = locale_charset(false);
}
so that it looks like this:
if( $use_html_checker )
{ // Check the code:
if( empty($encoding) )
{
// TODO: use $io_charset
$encoding = locale_charset(false);
}
if( ! $is_comment )
{
4. The last one is /b2evocore/_class_htmlchecker.php:
Replace the constructor with this:
/**
* SafeHtmlChecker(-)
*/
function SafeHtmlChecker( & $allowed_tags, & $allowed_attributes, & $uri_attrs, & $allowed_uri_scheme, $encoding = '' )
{
$this->tags = & $allowed_tags;
$this->tagattrs = & $allowed_attributes;
$this->uri_attrs = & $uri_attrs;
$this->allowed_uri_scheme = & $allowed_uri_scheme;
$encoding = strtoupper($encoding); // we might get 'iso-8859-1' for example
$this->encoding = $encoding;
if( ! in_array( $encoding, array( 'ISO-8859-1', 'UTF-8', 'US-ASCII' ) ) )
{ // passed encoding not supported by xml_parser_create()
$this->xml_parser_encoding = ''; // auto-detect (in PHP4, in PHP5 anyway)
}
else
{
$this->xml_parser_encoding = $this->encoding;
}
$this->parser = xml_parser_create( $this->xml_parser_encoding );
$this->last_checked_pos = 0;
$this->error = false;
// Creates the parser
xml_set_object( $this->parser, $this);
// set functions to call when a start or end tag is encountered
xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
// set function to call for the actual data
xml_set_character_data_handler($this->parser, 'cdata');
xml_set_default_handler($this->parser, 'default_handler');
xml_set_external_entity_ref_handler($this->parser, 'external_entity');
xml_set_unparsed_entity_decl_handler($this->parser, 'unparsed_entity');
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
}
and the "check()" method with this:
/**
* check(-)
*/
function check($xhtml)
{
// Convert encoding:
if( empty($this->xml_parser_encoding) || $this->encoding != $this->xml_parser_encoding )
{ // we need to convert encoding:
if( function_exists( 'mb_convert_encoding' ) )
{ // we can convert encoding
$supported_encodings = mb_list_encodings();
foreach( $supported_encodings as $k => $v )
{
$supported_encodings[$k] = strtoupper($v);
}
if( in_array( 'UTF-8', $supported_encodings ) )
{
$xhtml = mb_convert_encoding( $xhtml, 'UTF-8' );
$this->encoding = 'UTF-8';
}
}
}
// Open comments or '<![CDATA[' are dangerous
$xhtml = str_replace('<!', '', $xhtml);
// Convert isolated & chars
$xhtml = preg_replace( '#(\s)&(\s)#', '\\1&\\2', $xhtml );
$xhtml_head = '<?xml version="1.0"';
if( ! empty($this->encoding) )
{
$xhtml_head .= ' encoding="'.$this->encoding.'"';
}
$xhtml_head .= '?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
$xhtml = $xhtml_head.'<body>'.$xhtml.'</body>';
if (!xml_parse($this->parser, $xhtml))
{
$xml_error_code = xml_get_error_code( $this->parser );
$xml_error_string = xml_error_string( $xml_error_code );
switch( $xml_error_code )
{
case XML_ERROR_TAG_MISMATCH:
$xml_error_string .= ': <code>'.$this->stack[count($this->stack)-1].'</code>';
break;
}
$pos = xml_get_current_byte_index($this->parser);
$xml_error_string .= ' near <code>'.htmlspecialchars( substr( $xhtml, $this->last_checked_pos, $pos-$this->last_checked_pos+20 ) ).'</code>';
$this->html_error( T_('Parser error: ').$xml_error_string );
}
}
5 pvasili Apr 04, 2006 08:14
Big thank you :)
I try all you recommendation...
------------------------------------------
Strange occurrence: my old nik (pvasili) is down :(
6 blueyed Apr 04, 2006 19:21
In fact, it's not just a recommendation, but a proposed fix.. I hope it works out this way, otherwise you'll need to help me track this down.. :p
You can work around this problem, where I'm not sure what it's caused by, by temporarily(!) disabling the xhtml checker in /conf/_formatting.php: Set $use_html_checker = 0 there, change your blog settings and set it to 1 after that again.
About the problem: do you have any content in the "subtitle", "long description" or "notes" fields?
It might be a problem with the PHP xml_parser and the used encoding (while saving).