Escape quotes in strings properly. Fixes #1768.