WordPress.org

Ready to get started?Download WordPress

Forums

WP Facebook Open Graph protocol
[resolved] Removes CSS escaping backslash in theme editor (4 posts)

  1. Brent Logan
    Member
    Posted 1 year ago #

    When WP Facebook Open Graph protocol is active, backslashes from CSS escaped characters are being removed. For example:

    .next-comment-link a:before{content:"\2190"}

    loses the \ before 2190 when the editor displays the CSS file. Saving the file completes the loss of these backslashes.

    http://wordpress.org/extend/plugins/wp-facebook-open-graph-protocol/

  2. Dion Hulse
    WordPress Dev
    Posted 1 year ago #

    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.

  3. Chuck Reynolds
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  4. Brent Logan
    Member
    Posted 1 year ago #

    Wow, that was fast! Thanks. :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.