Project

General

Profile

Actions

Patch #44662

open

Avatar in the user edit title is inserted at the last space of the whole title HTML

Added by Jimmy Westberg 2 days ago. Updated 2 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Accounts / authentication
Target version:
-

Description

While creating this patch #44660 the following was discovered:

app/views/users/edit.html.erb puts the avatar into the page title by inserting it after the last space in the HTML returned by title:

page_title.insert(page_title.rindex(' ') + 1, avatar(@user).to_s)

This works today because the title ends with ยป login</h2> and a login has no spaces. But the search is not limited to the heading: if anything follows the <h2> in the returned HTML (for example a plugin that appends to the title through a helper override), the last space can be inside that markup, and the avatar is inserted there, which produces invalid HTML.

The attached patch limits the search to the heading, so the avatar is always placed before the login inside the <h2>:

page_title.insert(page_title.rindex(' ', page_title.index('</h2>')) + 1, avatar(@user).to_s)

The output is unchanged for core as it is. Against trunk.


Files

user-edit-avatar-title.patch (481 Bytes) user-edit-avatar-title.patch Jimmy Westberg, 2026-10-22 20:54

Related issues

Related to Redmine - Patch #5899: Display user's gravatar when editing profileClosedGo MAEDA2010-07-18Actions
Actions #1

Updated by Go MAEDA 2 days ago

  • Category changed from My page to Accounts / authentication
Actions #2

Updated by Go MAEDA 2 days ago

  • Related to Patch #5899: Display user's gravatar when editing profile added
Actions

Also available in: Atom PDF