Skip to content

Escape issue summary in search response#9

Open
g4mm4-VCF wants to merge 1 commit into
mantisbt-plugins:masterfrom
g4mm4-VCF:escape-summary-in-search-output
Open

Escape issue summary in search response#9
g4mm4-VCF wants to merge 1 commit into
mantisbt-plugins:masterfrom
g4mm4-VCF:escape-summary-in-search-output

Conversation

@g4mm4-VCF
Copy link
Copy Markdown

Summary

In pages/search.php, the issue summary is concatenated directly into the HTML payload returned in the JSON data field, then injected into the DOM by the client-side JS via $.fn.after() on bug_report_page.php. Because that path parses HTML, any markup-special character in a stored summary is reflected to anyone running the plugin's live search.

This patch pipes the summary through string_display_line(), which is MantisBT's standard helper for HTML-safe single-line output. The bug id is also cast to int defensively.

Change

- '">' . $t_issue->id . ": " . $t_issue->summary . '</a></li>';
+ '">' . (int)$t_issue->id . ": "
+     . string_display_line( $t_issue->summary ) . '</a></li>';

One line, no behaviour change for normal summaries, brings the plugin in line with MantisBT core's output-escaping convention. string_display_line() also fires the EVENT_DISPLAY_TEXT hook, so installed formatting plugins (e.g. MantisCoreFormatting) still get to do their own processing.

Test plan

  • Existing search behaviour unchanged for summaries that contain only plain text.
  • Summaries that contain <, >, &, etc. are rendered as text in the dropdown rather than parsed as markup.
  • Bug-id link still works (cast to int is a no-op for normal DB values).

Happy to coordinate further on a security advisory / release tag if useful.

The search response embeds raw HTML in a JSON 'data' field that the
plugin's client-side JS injects into the DOM via $.fn.after() on
bug_report_page.php. Pass the summary through string_display_line(),
the standard MantisBT helper for HTML-safe single-line output, so any
HTML characters in stored summaries are rendered as text instead of
parsed as markup.

Also defensively cast the bug id to int.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant