]> ruin.nu Git - ndwebbie.git/blobdiff - database/functions/escape_html.sql
Make use of the newish planet id from stats
[ndwebbie.git] / database / functions / escape_html.sql
diff --git a/database/functions/escape_html.sql b/database/functions/escape_html.sql
new file mode 100644 (file)
index 0000000..1c58cdb
--- /dev/null
@@ -0,0 +1,13 @@
+CREATE OR REPLACE FUNCTION escape_html(_unescaped text) RETURNS text
+    AS $_$
+DECLARE
+BEGIN
+       _unescaped := replace(_unescaped, '&', '&');
+       _unescaped := replace(_unescaped, '"', '"');
+       _unescaped := replace(_unescaped, '<', '&lt;');
+       _unescaped := replace(_unescaped, '>', '&gt;');
+       RETURN _unescaped;
+END;
+$_$
+    LANGUAGE plpgsql IMMUTABLE;
+