• Hi!

    I’m using the wp-syntax plugin, and I really like, but I have (had) a little problem with it. If there is a > sign in my code, > will be displayed on the site.

    I checked the plugin source, and the I find out that geshi cause the problem, because it converts > to >.

    There was a strange (standalone) return command in the line 95. I replaced it with the following: $output = str_replace(array(“&gt;”, “&lt;”), array(“>”, “<“), $output);, which solved my problem, but I think it is a Geshi bug, it shouldn’t has to replace a & which is part of an HTML entity.

    Best Regards,
    Felhő

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter felhobacsi

    (@felhobacsi)

    Hi!

    Now I checked Geshi’s source, and it seems, that Geshi always use its hsc() function, which acts as htmlspecialchars.

    So the solution to the problem would be to change this line:
    $geshi = new GeSHi($code, $language);
    To this:
    $geshi = new GeSHi(htmlspecialchars_decode($code), $language);

    I’m new to WP, but if I’am right if visual editor is off, WP won’t convert special charcters in the post, so maybe the above fix is not exactly correct.

    htmlspecialchars_decode is available from PHP 5.1, so we need the following code:
    if (!function_exists(“htmlspecialchars_decode”)) {
    function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) {
    return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
    }
    }

    Best Regards,
    Felhő

    Hát, az a wysiwyg állat mindent kódot szétkúr… abba soha nem szabad semmilyen kódot belerakni!

    moshubácsi

    Thread Starter felhobacsi

    (@felhobacsi)

    🙂 (köszi a választ, folytatom azért a kis béna angolommal :))

    I think this is a design flaw in WordPress, and this problem could not be solved correctly. The post don’t has a state, if its content was escaped or not, and you can not figure this out from the “rich_editing” state of the user, who created the post. The user’s state can change after creating the post, and even if it don’t, if the user create the post in code view, the content will be not escaped.

    Best Regards,
    Felhő

    Thread Starter felhobacsi

    (@felhobacsi)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘<, > problem again’ is closed to new replies.