Support » Plugin: WP Facebook Open Graph protocol » [Plugin: WP Facebook Open Graph protocol] Removes CSS escaping backslash in theme editor

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Dion Hulse

    (@dd32)

    Lead Developer

    FWIW, this is caused by the following lines in the output buffer:

    $content = stripslashes( preg_replace( '/<meta property="og:title" content="(.*)">/', '<meta property="og:title" content="' . preg_quote( $title_matches[1] ) . '">', $content ) );

    The stripslashes() appears to be added to remove the slashes added by preg_quote(), both can safely be removed.
    preg_quote() is designed to escape data being put into the regular expression (the first arg), there is no need to use regular expression escaping on the data being inserted there (although I’d still use esc_attr() where appropriate).

    eg:
    $content = preg_replace( '/<meta property="og:title" content="(.*)">/', '<meta property="og:title" content="' . esc_attr( $title_matches[1] ) . '">', $content ) );

    Although it was spotted as breaking the Theme editor, this would be also breaking cases where \ is entered into posts/etc.

    Rather than using a full-page output buffer, you may also want to investigate into using one which only captures the <head> (or at least, only applying to the front end) – although having to use a regular expression on such a large chunk of text in the first place is going to be bad for performance anyway.

    Plugin Author Chuck Reynolds

    (@ryno267)

    pushed 2.0.6 as rollback to fix. we’re working on a real fix w/ a rewrite so look for a bigger update soon.

    sorry for the inconvenience guys.

    Wow, that was fast! Thanks. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP Facebook Open Graph protocol] Removes CSS escaping backslash in theme editor’ is closed to new replies.