Escape apostrophe properly

Fix #1206