Skip to content

Commit

Permalink
Merge pull request #775 from Automattic/fix/#370
Browse files Browse the repository at this point in the history
FIX: Handle display name with special chars
  • Loading branch information
rebeccahum committed Apr 8, 2021
2 parents c9ebbd1 + 099e5d0 commit 371d757
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions co-authors-plus.php
Expand Up @@ -1205,8 +1205,17 @@ public function ajax_suggest() {
}

foreach ( $authors as $author ) {
$avatar_url = get_avatar_url( $author->ID );
echo esc_html( $author->ID . ' | ' . $author->user_login . ' | ' . $author->display_name . ' | ' . $author->user_email . ' | ' . rawurldecode( $author->user_nicename ) ) . ' | ' . esc_url( $avatar_url ) . "\n";
printf(
"%s ∣ %s ∣ %s ∣ %s ∣ %s ∣ %s \n",
esc_html( $author->ID ),
esc_html( $author->user_login ),
// Ensure that author names can contain a pipe character by replacing the pipe character with the
// divides character, which will now serve as a delimiter of the author parameters. (#370)
esc_html( str_replace( '∣', '|', $author->display_name ) ),
esc_html( $author->user_email ),
esc_html( rawurldecode( $author->user_nicename ) ),
esc_url( get_avatar_url( $author->ID ) )
);
}

die();
Expand Down Expand Up @@ -1376,7 +1385,7 @@ public function js_vars() {
?>
<script type="text/javascript">
// AJAX link used for the autosuggest
var coAuthorsPlus_ajax_suggest_link =
var coAuthorsPlus_ajax_suggest_link =
<?php
echo wp_json_encode(
add_query_arg(
Expand Down
4 changes: 2 additions & 2 deletions js/co-authors-plus.js
Expand Up @@ -193,7 +193,7 @@ jQuery( document ).ready(function () {
// Callback for when a user selects a co-author
function coauthors_autosuggest_select() {
$this = jQuery( this );
var vals = this.value.split( '|' );
var vals = this.value.split( '' );

var author = {}
author.id = jQuery.trim( vals[0] );
Expand Down Expand Up @@ -424,7 +424,7 @@ jQuery( document ).ready(function () {
avatar: jQuery( el ).data( 'avatar' ),
}
});

coauthors_initialize( post_coauthors );

}
Expand Down

0 comments on commit 371d757

Please sign in to comment.