Search results are displaying html entities in comment author fields rather than the values they represent. apachesolr_commentsearch_node_to_comments() assigns this field after escaping it with htmlspecialchars(), and I'm guessing this escaping occurs again somewhere in the pipeline.

Looking at apachesolr_node_to_document() from apachesolr.index.module, the document->name field is assigned the raw value from node->name. I've included a patch that does the same for apachesolr_commentsearch_node_to_comments().

CommentFileSizeAuthor
solr_comment_name_html_entities.patch1.21 KBkcoop

Comments

jpmckinney’s picture

Status: Needs work » Active

I can reproduce the problem.

You can't compare apachesolr_commentsearch_node_to_comments to apachesolr_node_to_document, as apachesolr_node_to_document uses the author's Drupal username, which we can safely assume contains no HTML special characters (usernames containing such characters are invalid). But a comment author's name isn't validated like a Drupal username.

Anyway, the problem is that theme('username', $doc) in apachesolr_search_process_response runs some comment author's names through check_plain, which double encodes the special characters. I'm not sure what is best to do in this case while still maintaining security. pwolanin should have a look.

jpmckinney’s picture

Status: Active » Needs review
jpmckinney’s picture

Status: Needs review » Needs work
jpmckinney’s picture

Title: Html entities erroneously generated for author names in apachesolr_commentsearch » [apachesolr_commentsearch] HTML entities erroneously generated for author names
Status: Active » Needs work
jpmckinney’s picture

Add tag

jpmckinney’s picture

Status: Needs work » Needs review

Actually, it looks like theme('username') is safe, and it will check plain the user name.

jpmckinney’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -apachesolr_commentsearch

Automatically closed -- issue fixed for 2 weeks with no activity.