Mercurial > emacs
annotate lisp/url/url-parse.el @ 107709:6db4a0b4404d
Merge from emacs-23 branch
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 30 Mar 2010 22:37:57 -0400 |
parents | 1d1d5d9bd884 |
children | fc2c0625a14a 376148b31b5e |
rev | line source |
---|---|
54695 | 1 ;;; url-parse.el --- Uniform Resource Locator parser |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
2 |
64748
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
5 |
54695 | 6 ;; Keywords: comm, data, processes |
7 | |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
9 ;; |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88005
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88005
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88005
diff
changeset
|
13 ;; (at your option) any later version. |
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88005
diff
changeset
|
14 |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
18 ;; GNU General Public License for more details. |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88005
diff
changeset
|
19 |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88005
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
22 |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
23 ;;; Commentary: |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
24 |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
25 ;;; Code: |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
26 |
54695 | 27 (require 'url-vars) |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
28 (eval-when-compile (require 'cl)) |
54695 | 29 |
30 (autoload 'url-scheme-get-property "url-methods") | |
31 | |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
32 (defstruct (url |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
33 (:constructor nil) |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
34 (:constructor url-parse-make-urlobj |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
35 (&optional type user password host portspec filename |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
36 target attributes fullness)) |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
37 (:copier nil)) |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
38 type user password host portspec filename target attributes fullness) |
54695 | 39 |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
40 (defsubst url-port (urlobj) |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
41 (or (url-portspec urlobj) |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
42 (if (url-fullness urlobj) |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
43 (url-scheme-get-property (url-type urlobj) 'default-port)))) |
54695 | 44 |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
45 (defsetf url-port (urlobj) (port) `(setf (url-portspec ,urlobj) ,port)) |
64748
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
46 |
54695 | 47 ;;;###autoload |
48 (defun url-recreate-url (urlobj) | |
54802 | 49 "Recreate a URL string from the parsed URLOBJ." |
54695 | 50 (concat (url-type urlobj) ":" (if (url-host urlobj) "//" "") |
51 (if (url-user urlobj) | |
52 (concat (url-user urlobj) | |
53 (if (url-password urlobj) | |
54 (concat ":" (url-password urlobj))) | |
55 "@")) | |
56 (url-host urlobj) | |
57 (if (and (url-port urlobj) | |
58 (not (equal (url-port urlobj) | |
59 (url-scheme-get-property (url-type urlobj) 'default-port)))) | |
60 (format ":%d" (url-port urlobj))) | |
72589
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
61 (or (url-filename urlobj) "/") |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
62 (url-recreate-url-attributes urlobj) |
54695 | 63 (if (url-target urlobj) |
72589
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
64 (concat "#" (url-target urlobj))))) |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
65 |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
66 (defun url-recreate-url-attributes (urlobj) |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
67 "Recreate the attributes of an URL string from the parsed URLOBJ." |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
68 (when (url-attributes urlobj) |
77220
4368e2079b5c
(url-generic-parse-url): Revert 2006-10-09 changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
75347
diff
changeset
|
69 (concat ";" |
72589
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
70 (mapconcat (lambda (x) |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
71 (if (cdr x) |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
72 (concat (car x) "=" (cdr x)) |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
73 (car x))) |
f6c1ac4c14c7
(url-recreate-url-attributes): New function, code moved from `url-recreate-url'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68640
diff
changeset
|
74 (url-attributes urlobj) ";")))) |
54695 | 75 |
76 ;;;###autoload | |
77 (defun url-generic-parse-url (url) | |
88005
858074177461
(url-generic-parse-url): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
78 "Return an URL-struct of the parts of URL. |
858074177461
(url-generic-parse-url): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
79 The CL-style struct contains the following fields: |
858074177461
(url-generic-parse-url): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
80 TYPE USER PASSWORD HOST PORTSPEC FILENAME TARGET ATTRIBUTES FULLNESS." |
73313
8c2a0bfc98b0
(url-generic-parse-url): Handle URLs with empty path component and
Magnus Henoch <mange@freemail.hu>
parents:
72589
diff
changeset
|
81 ;; See RFC 3986. |
54695 | 82 (cond |
83 ((null url) | |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
84 (url-parse-make-urlobj)) |
54695 | 85 ((or (not (string-match url-nonrelative-link url)) |
86 (= ?/ (string-to-char url))) | |
73313
8c2a0bfc98b0
(url-generic-parse-url): Handle URLs with empty path component and
Magnus Henoch <mange@freemail.hu>
parents:
72589
diff
changeset
|
87 ;; This isn't correct, as a relative URL can be a fragment link |
8c2a0bfc98b0
(url-generic-parse-url): Handle URLs with empty path component and
Magnus Henoch <mange@freemail.hu>
parents:
72589
diff
changeset
|
88 ;; (e.g. "#foo") and many other things (see section 4.2). |
8c2a0bfc98b0
(url-generic-parse-url): Handle URLs with empty path component and
Magnus Henoch <mange@freemail.hu>
parents:
72589
diff
changeset
|
89 ;; However, let's not fix something that isn't broken, especially |
8c2a0bfc98b0
(url-generic-parse-url): Handle URLs with empty path component and
Magnus Henoch <mange@freemail.hu>
parents:
72589
diff
changeset
|
90 ;; when close to a release. |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
91 (url-parse-make-urlobj nil nil nil nil nil url)) |
54695 | 92 (t |
74014
fd0232950658
(url-generic-parse-url): Use with-temp-buffer.
Magnus Henoch <mange@freemail.hu>
parents:
73313
diff
changeset
|
93 (with-temp-buffer |
106281
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
94 ;; Don't let those temp-buffer modifications accidentally |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
95 ;; deactivate the mark of the current-buffer. |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
96 (let ((deactivate-mark nil)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
97 (set-syntax-table url-parse-syntax-table) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
98 (let ((save-pos nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
99 (prot nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
100 (user nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
101 (pass nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
102 (host nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
103 (port nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
104 (file nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
105 (refs nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
106 (attr nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
107 (full nil) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
108 (inhibit-read-only t)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
109 (erase-buffer) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
110 (insert url) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
111 (goto-char (point-min)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
112 (setq save-pos (point)) |
73313
8c2a0bfc98b0
(url-generic-parse-url): Handle URLs with empty path component and
Magnus Henoch <mange@freemail.hu>
parents:
72589
diff
changeset
|
113 |
106281
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
114 ;; 3.1. Scheme |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
115 (unless (looking-at "//") |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
116 (skip-chars-forward "a-zA-Z+.\\-") |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
117 (downcase-region save-pos (point)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
118 (setq prot (buffer-substring save-pos (point))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
119 (skip-chars-forward ":") |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
120 (setq save-pos (point))) |
54695 | 121 |
106281
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
122 ;; 3.2. Authority |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
123 (when (looking-at "//") |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
124 (setq full t) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
125 (forward-char 2) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
126 (setq save-pos (point)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
127 (skip-chars-forward "^/") |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
128 (setq host (buffer-substring save-pos (point))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
129 (if (string-match "^\\([^@]+\\)@" host) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
130 (setq user (match-string 1 host) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
131 host (substring host (match-end 0) nil))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
132 (if (and user (string-match "\\([^:]+\\):\\(.*\\)" user)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
133 (setq pass (match-string 2 user) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
134 user (match-string 1 user))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
135 ;; This gives wrong results for IPv6 literal addresses. |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
136 (if (string-match ":\\([0-9+]+\\)" host) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
137 (setq port (string-to-number (match-string 1 host)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
138 host (substring host 0 (match-beginning 0)))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
139 (if (string-match ":$" host) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
140 (setq host (substring host 0 (match-beginning 0)))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
141 (setq host (downcase host) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
142 save-pos (point))) |
54695 | 143 |
106281
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
144 (if (not port) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
145 (setq port (url-scheme-get-property prot 'default-port))) |
54695 | 146 |
106281
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
147 ;; 3.3. Path |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
148 ;; Gross hack to preserve ';' in data URLs |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
149 (setq save-pos (point)) |
54695 | 150 |
106281
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
151 ;; 3.4. Query |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
152 (if (string= "data" prot) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
153 (goto-char (point-max)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
154 ;; Now check for references |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
155 (skip-chars-forward "^#") |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
156 (if (eobp) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
157 nil |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
158 (delete-region |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
159 (point) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
160 (progn |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
161 (skip-chars-forward "#") |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
162 (setq refs (buffer-substring (point) (point-max))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
163 (point-max)))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
164 (goto-char save-pos) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
165 (skip-chars-forward "^;") |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
166 (unless (eobp) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
167 (setq attr (url-parse-args (buffer-substring (point) (point-max)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
168 t) |
77220
4368e2079b5c
(url-generic-parse-url): Revert 2006-10-09 changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
75347
diff
changeset
|
169 attr (nreverse attr)))) |
54695 | 170 |
106281
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
171 (setq file (buffer-substring save-pos (point))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
172 (if (and host (string-match "%[0-9][0-9]" host)) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
173 (setq host (url-unhex-string host))) |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
174 (url-parse-make-urlobj |
b240f123834a
(url-generic-parse-url): Bind deactivate-mark.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
175 prot user pass host port file refs attr full))))))) |
54695 | 176 |
177 (provide 'url-parse) | |
54699 | 178 |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
179 ;; arch-tag: f338325f-71ab-4bee-93cc-78fb9a03d403 |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54802
diff
changeset
|
180 ;;; url-parse.el ends here |