]> git.ipfire.org Git - thirdparty/postgresql.git/commit
doc: Warn that ts_headline() output is not HTML-safe.
authorDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 1 May 2025 10:08:18 +0000 (11:08 +0100)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 1 May 2025 10:08:18 +0000 (11:08 +0100)
commit8b65f7106edb7914a13a90f318a0099be58d54ec
tree1b5356e7b41e36ba04623b8aed256664e457d2e9
parent0f404c5812471d21c1d006b4e5f354ca216cea22
doc: Warn that ts_headline() output is not HTML-safe.

Add a documentation warning to ts_headline() pointing out that, when
working with untrusted input documents, the output is not guaranteed
to be safe for direct inclusion in web pages. This is because, while
it does remove some XML tags from the input, it doesn't remove all
HTML markup, and so the result may be unsafe (e.g., it might permit
XSS attacks).

To guard against that, all HTML markup should be removed from the
input, making it plain text, or the output should be passed through an
HTML sanitizer.

In addition, document precisely what the default text search parser
recognises as valid XML tags, since that's what determines which XML
tags ts_headline() will remove.

Reported-by: Richard Neill <richard.neill@telos.digital>
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Backpatch-through: 13
doc/src/sgml/textsearch.sgml