You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Task Gantt ignores the browser width on PHP 8.1+ (htmlspecialchars() inside a JS string) #544
$src contains JavaScript (' + (...) + ') that is meant to compute the width in the browser. Since PHP 8.1, htmlspecialchars() defaults to ENT_QUOTES, so every ' becomes ':
Inside a <script> element entities aren't decoded, so the JS concatenation never runs; the HTML parser then decodes the entities when document.write() emits the <img>, and the browser requests width=' + ((navigator... literally. In modules/tasks/gantt.php L90, min(w2PgetParam($_GET, 'width', 600), 1400) compares that non-numeric string with 1400 and returns the string; GanttRenderer::__construct() casts it to (int) 0, so the chart is drawn at JpGraph's automatic width instead of 95% of the window.
The escaping is also in the wrong context: HTML-escaping a value that sits inside a JavaScript string literal. It isn't exploitable as written (the entities keep quotes inert), but it's the pattern behind #542.
Found by code reading on master 8727ad5 and by running htmlspecialchars() on PHP 8; not yet checked in a browser.
Proposed fix
Same helper as #542 / #543: build the server-side query with http_build_query() (casting the flags and ids to int), output a plain <img>, and set its src from JS using json_encode() for the server part plus the computed width. Also make gantt.php read the width with (int) before min(), with a sane lower bound.
Testing
Project → Gantt tab on PHP 8.1+: before the fix the image request has width=%27%20+%20((navigator...; after it, width=<number> and the chart fills ~95% of the window.
Activity