Using a MySQL trigger to replace input -


is possible create trigger that, upon inserting or updating row, can use replace function replace characters escaped equivalents (specifically, making input html safe) columns in table without having know field names (so function can applied multiple tables). agree 115% sort of thing should done @ application level, due unique circumstances i'd add failsafe @ database level.

i'm new triggers, take easy on me, want effect of:

create trigger if not exists makehtmlsafe after insert on tablename begin   loop on columns in tablename        new.value = replace(old.value,"<","&lt;") end 

escaping complicated , error-prone.
should never try roll own escaping function, risky.

instead of making things more secure make far less secure.
use specialized html escaping functions in front-end.

when using php, htmlentities best bet:

http://php.net/manual/en/function.htmlentities.php
see also: what best practices avoiding xss attacks in php site


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -