From https://stackoverflow.com/questions/7744912/making-a-javascript-string-sql-friendly