Encode all the URLs

Proposed fixes for #12216 and #11035.