Fix symlinks being destroyed when editing them.

With this fix we dereference the link and edit the pointed-to file
instead.

Fixes issue 2363.
(cherry picked from commit 58a897220c3c9f2f20f05b3562dbe5c6bbe50269)
Include fix for 2363