- (let* ((address (elpher-address-from-url (elpher-decode (url-unhex-string url))))
- (host (url-host address))
- (pass (url-password address)))
- (when host
- (setf (url-host address) (puny-decode-domain host)))
- (when pass ; RFC 3986 says we should not render
- (setf (url-password address) nil)) ; the password as clear text
- (url-recreate-url address)))
-
-(defun elpher-encode-url (iri)
- "Return an URL for the IRI.
-Encode and use percent-escapes, use punycode for the domain name
-if necessary."
- (let* ((address (url-generic-parse-url iri))
- (host (url-host address)))
- (when host
- (setf (url-host address) (puny-encode-domain host)))
- (url-recreate-url address)))
+ (let ((data (match-data))) ; Prevent parsing clobbering match data
+ (unwind-protect
+ (let* ((host (url-host address))
+ (pass (url-password address)))
+ (when host
+ (setf (url-host address) (puny-decode-domain host)))
+ (when pass ; RFC 3986 says we should not render
+ (setf (url-password address) nil)) ; the password as clear text
+ (url-recreate-url address))
+ (set-match-data data))))