Support » Plugin: WP Alternative Post Title » Plugin can unintentionally truncate the alternate title (fix provided)

  • In version 0.1 of the WP Alternative Post Title plugin there is a bug. When it generates the input field for the alternative title, on the post edit page, it does not HTML escape the existing string put in the value attribute. This can result in it being truncated by the broswer, depending on the value. For example if the alternative title is…

    An alternative title containing “quotes” that are very interesting

    … when the post is edited the input field will only be populated with..

    An alternative title containing

    … by the broswer since it believes the first quote, in the alternative title string, is actually the closing quote of the value attribute.

    So if you then save the post you will have unintentionally truncated the alternative title.

    To fix this you need to edit line 45 of the plugin file wp-multiple-titles.php to escape the value attribute, using the esc_attr function.

    Previous function:

    
    //check if there's already a title to display
    function alternative_title_display($post) {
            $title = get_post_meta($post->ID,'alternative_title',true);
            echo '<input id="alt_title" type="text" name="alt_title" value="' . $title . '" style="width:100%"/>';
    }
    

    New function:

    
    //check if there's already a title to display
    function alternative_title_display($post) {
            $title = get_post_meta($post->ID,'alternative_title',true);
            echo '<input id="alt_title" type="text" name="alt_title" value="' . esc_attr($title) . '" style="width:100%"/>';
    }
    • This topic was modified 10 months, 2 weeks ago by sconaty.
  • The topic ‘Plugin can unintentionally truncate the alternate title (fix provided)’ is closed to new replies.