Skip to content

Tasks ID And Hover Card PR Review

Ed Mozley edited this page Nov 21, 2026 · 2 revisions

Task ID, a Company column and a details card on hover - review

#405 by @cloudcogsio · Verdict: merge, with fixes · 5.8.0 (#3031)

Three small things that make tasks easier to find and read. User page: Tasks.

  • The task ID shows as #ID before the title on every board card, as a column in the board's List view (sorted as a number - compared as text, #10 would come before #9), and as an optional ID column in the Table.
  • A Company column in the Table, hidden by default, so "All companies" no longer mixes every company's tasks with no way to tell them apart.
  • A details card on hover in the Calendar (month and week) and the Timeline (bars and names), replacing a one-line browser tooltip: ID, status, title, parent task, priority, assignee, team, project, contractor, dates with Overdue, subtask progress, tags and the start of the description. It is placed so it never leaves the window, is not shown while a bar is dragged or on touch screens, and is one file, assets/js/tasks-hover-card.js, that each page starts with its own selector.

What was checked

Question Result
Is everything on the card escaped? Yes - every value goes through esc(), which escapes all five HTML characters, including quotes
Can a colour from the database break out of a style? No - status, priority, project and tag colours are used only if they are a hex colour (colour()); anything else gets a grey
What do the pages put in the markup? Only data-hc="h<number>" - a key into a lookup the card keeps - never task data
Does the Company column reveal companies? No - it reads get_tenants.php?accessible=1, the same list the right-click Move to company uses
Schema, API, permissions None changed

What was fixed

1. The description excerpt could run script

To show the start of a description as plain text, the card did what many scripts do:

const div = document.createElement('div');
div.innerHTML = html;          // the task's description
const text = div.textContent;

It looks harmless - the div is never added to the page. But an element made by document.createElement belongs to the live document, and the browser starts loading its images as soon as they are parsed, attached or not. A description containing <img src=x onerror="..."> would run that script the moment someone rested the pointer on the task.

Descriptions are cleaned when they are saved, so this needed bad HTML to be stored first. The card must not depend on that, so it now parses into a separate, inert document:

const doc = new DOMParser().parseFromString(html, 'text/html');
const text = doc.body.textContent;   // nothing in doc loads or runs

Proved side by side on a test install: the same planted image fired its handler through the old code and not through the new one.

2. The same pattern in the phone change editor

A sweep for the pattern found it once more, in assets/js/mobile.js - the excerpt on the phone's rich-text cards in the change editor, whose comment said the detached div made it safe. It got the same fix and the same TRAP: comment. (Elsewhere the pattern only ever receives HTML that has already been through the sanitiser - knowledge.js even says why.)

3. Merge conflicts and translations

The conflicts were all cache-busters on the seven Tasks pages: inbox.css?v=97 from main and tasks.css?v=61 from the branch. The new strings - the ID column, the card's two labels and four help paragraphs - are in the eight languages kept at 100%.

📁 Files

File Change
🟡 assets/js/tasks-hover-card.js New: the card. Excerpt via DOMParser
🟡 assets/js/tasks.js, assets/js/tasks-timeline.js, assets/js/tasks-calendar.js #ID on cards, the List ID column, data-hc instead of title
🟡 assets/js/mobile.js The same excerpt fix (mobile.js?v=87)
🔵 assets/css/tasks.css Card styles (tasks.css?v=61)
🟣 tasks/*.php The Table's ID and Company columns, scripts and cache-busters
🌐 lang/*/tasks.php list.col_id, hover.*, four help lines

Related: Developer Guide · Code traps · Tasks

FreeITSM

Getting Started

Modules

Multi-tenancy (planned)

Responses to feedback

Blue sky thinking

Bugs resolved

Pull requests

Links

Clone this wiki locally