libdb: add function to check for dangerous characters