aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-11-27 01:27:04 +0000
committerStefan Monnier2009-11-27 01:27:04 +0000
commitc074ba4a567963720aefde4d38c447660d09e330 (patch)
treecbdd36e8ab6b641b97476b96dd5dc2a322d16238
parentbe1674ab1b210a3aafb3b05e7ad52e5e0c5528b9 (diff)
downloademacs-c074ba4a567963720aefde4d38c447660d09e330.tar.gz
emacs-c074ba4a567963720aefde4d38c447660d09e330.zip
(url-generic-parse-url): Bind deactivate-mark.
-rw-r--r--lisp/url/ChangeLog4
-rw-r--r--lisp/url/url-parse.el158
2 files changed, 84 insertions, 78 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 91cafbb8cce..0091ba1171a 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,7 @@
12009-11-27 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * url-parse.el (url-generic-parse-url): Bind deactivate-mark.
4
12009-11-08 Kai Tetzlaff <kai.tetzlaff@web.de> (tiny change) 52009-11-08 Kai Tetzlaff <kai.tetzlaff@web.de> (tiny change)
2 6
3 * url-http.el (url-http-handle-authentication): Use proxy server, 7 * url-http.el (url-http-handle-authentication): Use proxy server,
diff --git a/lisp/url/url-parse.el b/lisp/url/url-parse.el
index 254a2167112..659329ab81e 100644
--- a/lisp/url/url-parse.el
+++ b/lisp/url/url-parse.el
@@ -91,86 +91,88 @@ TYPE USER PASSWORD HOST PORTSPEC FILENAME TARGET ATTRIBUTES FULLNESS."
91 (url-parse-make-urlobj nil nil nil nil nil url)) 91 (url-parse-make-urlobj nil nil nil nil nil url))
92 (t 92 (t
93 (with-temp-buffer 93 (with-temp-buffer
94 (set-syntax-table url-parse-syntax-table) 94 ;; Don't let those temp-buffer modifications accidentally
95 (let ((save-pos nil) 95 ;; deactivate the mark of the current-buffer.
96 (prot nil) 96 (let ((deactivate-mark nil))
97 (user nil) 97 (set-syntax-table url-parse-syntax-table)
98 (pass nil) 98 (let ((save-pos nil)
99 (host nil) 99 (prot nil)
100 (port nil) 100 (user nil)
101 (file nil) 101 (pass nil)
102 (refs nil) 102 (host nil)
103 (attr nil) 103 (port nil)
104 (full nil) 104 (file nil)
105 (inhibit-read-only t)) 105 (refs nil)
106 (erase-buffer) 106 (attr nil)
107 (insert url) 107 (full nil)
108 (goto-char (point-min)) 108 (inhibit-read-only t))
109 (setq save-pos (point)) 109 (erase-buffer)
110 110 (insert url)
111 ;; 3.1. Scheme 111 (goto-char (point-min))
112 (if (not (looking-at "//")) 112 (setq save-pos (point))
113 (progn 113
114 (skip-chars-forward "a-zA-Z+.\\-") 114 ;; 3.1. Scheme
115 (downcase-region save-pos (point)) 115 (unless (looking-at "//")
116 (setq prot (buffer-substring save-pos (point))) 116 (skip-chars-forward "a-zA-Z+.\\-")
117 (skip-chars-forward ":") 117 (downcase-region save-pos (point))
118 (setq save-pos (point)))) 118 (setq prot (buffer-substring save-pos (point)))
119 119 (skip-chars-forward ":")
120 ;; 3.2. Authority 120 (setq save-pos (point)))
121 (if (looking-at "//") 121
122 (progn 122 ;; 3.2. Authority
123 (setq full t) 123 (when (looking-at "//")
124 (forward-char 2) 124 (setq full t)
125 (setq save-pos (point)) 125 (forward-char 2)
126 (skip-chars-forward "^/") 126 (setq save-pos (point))
127 (setq host (buffer-substring save-pos (point))) 127 (skip-chars-forward "^/")
128 (if (string-match "^\\([^@]+\\)@" host) 128 (setq host (buffer-substring save-pos (point)))
129 (setq user (match-string 1 host) 129 (if (string-match "^\\([^@]+\\)@" host)
130 host (substring host (match-end 0) nil))) 130 (setq user (match-string 1 host)
131 (if (and user (string-match "\\([^:]+\\):\\(.*\\)" user)) 131 host (substring host (match-end 0) nil)))
132 (setq pass (match-string 2 user) 132 (if (and user (string-match "\\([^:]+\\):\\(.*\\)" user))
133 user (match-string 1 user))) 133 (setq pass (match-string 2 user)
134 ;; This gives wrong results for IPv6 literal addresses. 134 user (match-string 1 user)))
135 (if (string-match ":\\([0-9+]+\\)" host) 135 ;; This gives wrong results for IPv6 literal addresses.
136 (setq port (string-to-number (match-string 1 host)) 136 (if (string-match ":\\([0-9+]+\\)" host)
137 host (substring host 0 (match-beginning 0)))) 137 (setq port (string-to-number (match-string 1 host))
138 (if (string-match ":$" host) 138 host (substring host 0 (match-beginning 0))))
139 (setq host (substring host 0 (match-beginning 0)))) 139 (if (string-match ":$" host)
140 (setq host (downcase host) 140 (setq host (substring host 0 (match-beginning 0))))
141 save-pos (point)))) 141 (setq host (downcase host)
142 142 save-pos (point)))
143 (if (not port) 143
144 (setq port (url-scheme-get-property prot 'default-port))) 144 (if (not port)
145 145 (setq port (url-scheme-get-property prot 'default-port)))
146 ;; 3.3. Path 146
147 ;; Gross hack to preserve ';' in data URLs 147 ;; 3.3. Path
148 (setq save-pos (point)) 148 ;; Gross hack to preserve ';' in data URLs
149 149 (setq save-pos (point))
150 ;; 3.4. Query 150
151 (if (string= "data" prot) 151 ;; 3.4. Query
152 (goto-char (point-max)) 152 (if (string= "data" prot)
153 ;; Now check for references 153 (goto-char (point-max))
154 (skip-chars-forward "^#") 154 ;; Now check for references
155 (if (eobp) 155 (skip-chars-forward "^#")
156 nil 156 (if (eobp)
157 (delete-region 157 nil
158 (point) 158 (delete-region
159 (progn 159 (point)
160 (skip-chars-forward "#") 160 (progn
161 (setq refs (buffer-substring (point) (point-max))) 161 (skip-chars-forward "#")
162 (point-max)))) 162 (setq refs (buffer-substring (point) (point-max)))
163 (goto-char save-pos) 163 (point-max))))
164 (skip-chars-forward "^;") 164 (goto-char save-pos)
165 (if (not (eobp)) 165 (skip-chars-forward "^;")
166 (setq attr (url-parse-args (buffer-substring (point) (point-max)) t) 166 (unless (eobp)
167 (setq attr (url-parse-args (buffer-substring (point) (point-max))
168 t)
167 attr (nreverse attr)))) 169 attr (nreverse attr))))
168 170
169 (setq file (buffer-substring save-pos (point))) 171 (setq file (buffer-substring save-pos (point)))
170 (if (and host (string-match "%[0-9][0-9]" host)) 172 (if (and host (string-match "%[0-9][0-9]" host))
171 (setq host (url-unhex-string host))) 173 (setq host (url-unhex-string host)))
172 (url-parse-make-urlobj 174 (url-parse-make-urlobj
173 prot user pass host port file refs attr full)))))) 175 prot user pass host port file refs attr full)))))))
174 176
175(provide 'url-parse) 177(provide 'url-parse)
176 178