Properly urlencode urls used in HTML attributes. This solves issues with invalid HTML being generated when paths contain special characters. Fixes #3395