Fix #1540 "Attachment with filename containing ampersand is not saved"

- use getRawQuery
- also use the getRaw* methods in a few other places