xssbook2/db/rest/util/_api_trim.sql

26 lines
398 B
MySQL
Raw Normal View History

CREATE FUNCTION _api.trim(
_text TEXT
)
RETURNS TEXT
LANGUAGE plpgsql VOLATILE
AS $BODY$
DECLARE
_new TEXT;
BEGIN
IF _text IS NULL THEN
RETURN NULL;
END IF;
_new = _text;
_new = TRIM(_new);
_new = REGEXP_REPLACE(_new, '^(?: |\r|\n)*', '');
_new = REGEXP_REPLACE(_new, '(?: |\r|\n)*$', '');
RETURN _new;
END
$BODY$;
GRANT EXECUTE ON FUNCTION _api.trim(TEXT)
TO rest_anon, rest_user;