Gleaned somewhere off the internet (sorry, my searching is now coming up blank),
| Excerpt |
|---|
this |
function is the best way to encode HTML in PostgreSQL |
| Code Block | ||||
|---|---|---|---|---|
| ||||
-- A useful function for HTML-encoding a string
create or replace function encodehtml(str text) returns text AS
$$
BEGIN
return
CASE WHEN str is not null THEN
regexp_replace(xmlelement(name x, str, null)::text, '</?x>', '', 'g')
ELSE
null
END;
END; $$ language 'plpgsql'; |
...