Fix crash on adding attachments, due to replacing range out of bounds.
Merge pull request #29 from kishikawakatsumi/fix_replace

Fix crash on adding attachments, due to replacing range out of bounds.