Page 1 of 1

[BUG] - Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Wed Oct 26, 2005 3:35 am
by energumeno
Hi,

i posted this on the developer zone but after reading the Purpose of this forum (http://forum.joomla.org/index.php/topic,11776.0.html), i thought it was more suited to be here.

http://forum.joomla.org/index.php/topic,13846.0.html


it is about the problem mospagebreak has when parsing a title with special characters. the issue is well explained on the first post of the thread and on the second i proposed what i think is a suitable solution to the problem or at least a much better one that what is being done.

Please read the post mentioned above to understand the problem.

To summarize it, the createTOC() function in JOOMLA_FOLDER/mambots/content/mospaging.php uses the parse_str() PHP function 3 times within lines 145 to 185 which parses the string as if it were a url querystring.

The problem is that the editor, stores every special character as its htmlencode equivalent which introduces some ampersands in the string and breaks the title when its being parsed.

My proposed solution is the following:

change every line that does parse_str:

Code: Select all

parse_str( str_replace( '&', '&', $bot[2] ), $args2 );
with

Code: Select all

parse_str( html_entity_decode( $bot[2] ), $args2 );
which will replace back the special characters from its htmlencode entity to the character itself.

but if an & is entered which will be converted to & the title will still be truncated, so my solution works for 99% of the cases but i suggest if mospagebreak doesn't have any other parameter besides title, to use whatever is placed after "title=" as the title for the TOC which completely solves the problem.


hope this is helpful

[BUG] - Re: Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Wed Oct 26, 2005 8:42 am
by Jinx
Could u add this problem to the bugtracker for 1.0.x and post a link back to this forum post. Thanks.

Re: Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Thu Oct 27, 2005 3:07 am
by energumeno
Done ...

artifact: artf1809

http://developer.joomla.org/sf/go/artf1809?nav=1

Thanks

Re: [BUG] - Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Tue Nov 22, 2005 5:52 pm
by kikeluke
Hola Darío,

Gracias por resolver el problema, aunque no sé si lo he hecho correctamente ya que sí me funcionan los carácteres especiales de los botones del menú "title", pero no ocurre lo mismo con la cabecera, ya sabes, el atributo "heading".

De cualquier manera muchas gracias.  :D

Re: [BUG] - Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Mon Jun 18, 2007 6:47 am
by viet4777
Special Characters:
Image
Some unicode charecter cannot display in Title of MOSpagebreak, such as â, ê,..., the charecters will be replaced by ? character (see image).

I use Joomla 1.0.12

How to correct this.

Re: [BUG] - Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Mon Jun 18, 2007 8:24 am
by jcisio
This is just a workaround for the problem. Example: http://tintucvienthong.com/article/275/

About line 196 in mambots/content/mospagebreak.php
                        // jcisio: fix for entities in Vi
                        $bot[2] = str_replace('&', '|', $bot[2]);
                        parse_str( html_entity_decode( $bot[2] ), $args2 );
                      $args2 = str_replace('|', '&', $args2);
Of course, change '|' to anything you like, for instance chr(255). I don't use more than 1 parametres in mospagebreak so it's ok.

Re: [BUG] - Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Mon Jun 18, 2007 8:39 am
by viet4777
Hi, friend,

I have fixed following this instruction from: http://forum.joomla.org/index.php/topic,13846.0.html .

And

Vietnamese users, please visit this link: http://www.joomlaviet.org/forum/index.p ... 025.0.html

Re: [BUG] - Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Mon Jun 18, 2007 8:53 am
by jcisio
viet4777 wrote: Hi, friend,

I have fixed following this instruction from: http://forum.joomla.org/index.php/topic,13846.0.html .
The first instruction is incomplete (for example there're many symbols à è... it doesn't process). The second suggestion works, and it's something implemented in Joomla! 1.0.12 (with some modifs...) and it still has problems. So I suggest my workaround. And I don't care if it's dirty, as mospagebreak is changed in Joomla! 1.5

For PHP fans, the syntax of str_replace in PHP is str_replace(mixed, mixed, mixed), so don't hesistate to use array.
viet4777 wrote: And

Vietnamese users, please visit this link: http://www.joomlaviet.org/forum/index.p ... 025.0.html
Poor me. I've been banned from that site.

Re: [BUG] - Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Mon Jun 18, 2007 9:05 am
by viet4777
Many Thanks,

Here is the code for Vietnamese characters:
parse_str(
str_replace( 'â', 'â',
str_replace( 'ê', 'ê',
str_replace( 'ô', 'ô',
str_replace( 'á', 'á',
str_replace( 'é', 'é',
str_replace( 'ó', 'ó',
str_replace( 'ò', 'ò',
str_replace( 'õ', 'õ',
str_replace( 'í', 'í',
str_replace( 'ì', 'ì',
str_replace( 'ã', 'ã',
str_replace( 'à', 'à',
$bot[2] ))))))))))))
, $args2
);
I do not know much about coding, I try and see it OK, it means Ok for me!  :laugh:.

Re: [BUG] - Proposed Solution to mospagebreak problem with "Special Characters"

Posted: Mon Jun 18, 2007 9:12 am
by jcisio
Thanks for your contribution. Still lack of some, and capital letters also.
You might use this reference to complete your code. http://www.cs.tut.fi/~jkorpela/html/guide/entities.html (official version, but more complex http://www.w3.org/TR/html4/sgml/entities.html)