pgsql: doc: Warn that ts_headline() output is not HTML-safe.

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: doc: Warn that ts_headline() output is not HTML-safe.
Date: 2025-05-01 10:13:09
Message-ID: E1uAQuj-000SSl-2J@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)neill(at)telos(dot)digital>
Author: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Reviewed-by: Noah Misch <noah(at)leadboat(dot)com>
Backpatch-through: 13

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/18dc43a07fecc22934742fd752dcdd3a10f9d6cd

Modified Files
--------------
doc/src/sgml/textsearch.sgml | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2025-05-01 12:42:05 Re: pgsql: Add function to log the memory contexts of specified backend pro
Previous Message Fujii Masao 2025-05-01 07:53:41 Re: pgsql: Add function to log the memory contexts of specified backend pro