Mercurial > pidgin.yaz
comparison libgaim/gaim-url-handler @ 14535:e3a640372b6e
[gaim-migrate @ 17256]
Sean requested case-insensitive matching on command, and noted that the plus sign wasn't being unescaped to a space. Both are fixed now.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 11 Sep 2006 22:57:41 +0000 |
parents | 82b59abcaee4 |
children | b007392d72ff |
comparison
equal
deleted
inserted
replaced
14534:79adfd5ac0b9 | 14535:e3a640372b6e |
---|---|
82 match = re.match(r"^(aim|icq):([^?]*)(\?(.*))", uri) | 82 match = re.match(r"^(aim|icq):([^?]*)(\?(.*))", uri) |
83 if not match: | 83 if not match: |
84 print "Invalid aim URI: %s" % uri | 84 print "Invalid aim URI: %s" % uri |
85 return | 85 return |
86 | 86 |
87 command = urllib.unquote(match.group(2)) | 87 command = urllib.unquote_plus(match.group(2)) |
88 paramstring = match.group(4) | 88 paramstring = match.group(4) |
89 params = {} | 89 params = {} |
90 if paramstring: | 90 if paramstring: |
91 for param in paramstring.split("&"): | 91 for param in paramstring.split("&"): |
92 key, value = extendlist(param.split("=", 1), 2, "") | 92 key, value = extendlist(param.split("=", 1), 2, "") |
93 params[key] = urllib.unquote(value) | 93 params[key] = urllib.unquote_plus(value) |
94 accountname = params.get("account", "") | 94 accountname = params.get("account", "") |
95 screenname = params.get("screenname", "") | 95 screenname = params.get("screenname", "") |
96 | 96 |
97 account = findaccount(protocol, accountname) | 97 account = findaccount(protocol, accountname) |
98 | 98 |
99 if command == "goim": | 99 if command.lower() == "goim": |
100 goim(account, screenname, params.get("message")) | 100 goim(account, screenname, params.get("message")) |
101 elif command == "gochat": | 101 elif command.lower() == "gochat": |
102 gochat(account, params) | 102 gochat(account, params) |
103 elif command == "addbuddy": | 103 elif command.lower() == "addbuddy": |
104 addbuddy(account, screenname, params.get("group", "")) | 104 addbuddy(account, screenname, params.get("group", "")) |
105 | 105 |
106 def gg(uri): | 106 def gg(uri): |
107 protocol = "prpl-gg" | 107 protocol = "prpl-gg" |
108 match = re.match(r"^gg:(.*)", uri) | 108 match = re.match(r"^gg:(.*)", uri) |
109 if not match: | 109 if not match: |
110 print "Invalid gg URI: %s" % uri | 110 print "Invalid gg URI: %s" % uri |
111 return | 111 return |
112 | 112 |
113 screenname = urllib.unquote(match.group(1)) | 113 screenname = urllib.unquote_plus(match.group(1)) |
114 account = findaccount(protocol) | 114 account = findaccount(protocol) |
115 goim(account, screenname) | 115 goim(account, screenname) |
116 | 116 |
117 def icq(uri): | 117 def icq(uri): |
118 aim(uri) | 118 aim(uri) |
122 match = re.match(r"^irc:(//([^/]*)/)?([^?]*)(\?(.*))?", uri) | 122 match = re.match(r"^irc:(//([^/]*)/)?([^?]*)(\?(.*))?", uri) |
123 if not match: | 123 if not match: |
124 print "Invalid irc URI: %s" % uri | 124 print "Invalid irc URI: %s" % uri |
125 return | 125 return |
126 | 126 |
127 server = urllib.unquote(match.group(2)) or "" | 127 server = urllib.unquote_plus(match.group(2)) or "" |
128 target = match.group(3) or "" | 128 target = match.group(3) or "" |
129 query = match.group(5) or "" | 129 query = match.group(5) or "" |
130 | 130 |
131 modifiers = {} | 131 modifiers = {} |
132 if target: | 132 if target: |
138 paramstring = match.group(5) | 138 paramstring = match.group(5) |
139 params = {} | 139 params = {} |
140 if paramstring: | 140 if paramstring: |
141 for param in paramstring.split("&"): | 141 for param in paramstring.split("&"): |
142 key, value = extendlist(param.split("=", 1), 2, "") | 142 key, value = extendlist(param.split("=", 1), 2, "") |
143 params[key] = urllib.unquote(value) | 143 params[key] = urllib.unquote_plus(value) |
144 | 144 |
145 account = findaccount(protocol) | 145 account = findaccount(protocol) |
146 | 146 |
147 if (target != ""): | 147 if (target != ""): |
148 if (isnick): | 148 if (isnick): |
149 goim(account, urllib.unquote(target.split(",")[0]), params.get("msg")) | 149 goim(account, urllib.unquote_plus(target.split(",")[0]), params.get("msg")) |
150 else: | 150 else: |
151 channel = urllib.unquote(target.split(",")[0]) | 151 channel = urllib.unquote_plus(target.split(",")[0]) |
152 if channel[0] != "#": | 152 if channel[0] != "#": |
153 channel = "#" + channel | 153 channel = "#" + channel |
154 gochat(account, {"server": server, "channel": channel, "password": params.get("key", "")}, params.get("msg")) | 154 gochat(account, {"server": server, "channel": channel, "password": params.get("key", "")}, params.get("msg")) |
155 | 155 |
156 def msnim(uri): | 156 def msnim(uri): |
158 match = re.match(r"^msnim:([^?]*)(\?(.*))", uri) | 158 match = re.match(r"^msnim:([^?]*)(\?(.*))", uri) |
159 if not match: | 159 if not match: |
160 print "Invalid msnim URI: %s" % uri | 160 print "Invalid msnim URI: %s" % uri |
161 return | 161 return |
162 | 162 |
163 command = urllib.unquote(match.group(1)) | 163 command = urllib.unquote_plus(match.group(1)) |
164 paramstring = match.group(3) | 164 paramstring = match.group(3) |
165 params = {} | 165 params = {} |
166 if paramstring: | 166 if paramstring: |
167 for param in paramstring.split("&"): | 167 for param in paramstring.split("&"): |
168 key, value = extendlist(param.split("=", 1), 2, "") | 168 key, value = extendlist(param.split("=", 1), 2, "") |
169 params[key] = urllib.unquote(value) | 169 params[key] = urllib.unquote_plus(value) |
170 screenname = params.get("contact", "") | 170 screenname = params.get("contact", "") |
171 | 171 |
172 account = findaccount(protocol) | 172 account = findaccount(protocol) |
173 | 173 |
174 if command == "chat": | 174 if command.lower() == "chat": |
175 goim(account, screenname) | 175 goim(account, screenname) |
176 elif command == "add": | 176 elif command.lower() == "add": |
177 addbuddy(account, screenname) | 177 addbuddy(account, screenname) |
178 | 178 |
179 def sip(uri): | 179 def sip(uri): |
180 protocol = "prpl-simple" | 180 protocol = "prpl-simple" |
181 match = re.match(r"^sip:(.*)", uri) | 181 match = re.match(r"^sip:(.*)", uri) |
182 if not match: | 182 if not match: |
183 print "Invalid sip URI: %s" % uri | 183 print "Invalid sip URI: %s" % uri |
184 return | 184 return |
185 | 185 |
186 screenname = urllib.unquote(match.group(1)) | 186 screenname = urllib.unquote_plus(match.group(1)) |
187 account = findaccount(protocol) | 187 account = findaccount(protocol) |
188 goim(account, screenname) | 188 goim(account, screenname) |
189 | 189 |
190 def xmpp(uri): | 190 def xmpp(uri): |
191 protocol = "prpl-jabber" | 191 protocol = "prpl-jabber" |
192 match = re.match(r"^xmpp:(//([^/?#]*))?(/?([^?#]*))(\?([^;#]*)(;([^#]*))?)?(#(.*))?", uri) | 192 match = re.match(r"^xmpp:(//([^/?#]*))?(/?([^?#]*))(\?([^;#]*)(;([^#]*))?)?(#(.*))?", uri) |
193 if not match: | 193 if not match: |
194 print "Invalid xmpp URI: %s" % uri | 194 print "Invalid xmpp URI: %s" % uri |
195 return | 195 return |
196 | 196 |
197 accountname = urllib.unquote(match.group(2)) or "" | 197 accountname = urllib.unquote_plus(match.group(2)) or "" |
198 screenname = urllib.unquote(match.group(4)) | 198 screenname = urllib.unquote_plus(match.group(4)) |
199 command = urllib.unquote(match.group(6)) | 199 command = urllib.unquote_plus(match.group(6)) |
200 paramstring = match.group(8) | 200 paramstring = match.group(8) |
201 params = {} | 201 params = {} |
202 if paramstring: | 202 if paramstring: |
203 for param in paramstring.split(";"): | 203 for param in paramstring.split(";"): |
204 key, value = extendlist(param.split("=", 1), 2, "") | 204 key, value = extendlist(param.split("=", 1), 2, "") |
205 params[key] = urllib.unquote(value) | 205 params[key] = urllib.unquote_plus(value) |
206 | 206 |
207 account = findaccount(protocol, accountname) | 207 account = findaccount(protocol, accountname) |
208 | 208 |
209 if command == "message": | 209 if command.lower() == "message": |
210 goim(account, screenname, params.get("body")) | 210 goim(account, screenname, params.get("body")) |
211 elif command == "join": | 211 elif command.lower() == "join": |
212 room, server = screenname.split("@") | 212 room, server = screenname.split("@") |
213 gochat(account, {"room": room, "server": server}) | 213 gochat(account, {"room": room, "server": server}) |
214 elif command == "roster": | 214 elif command.lower() == "roster": |
215 addbuddy(account, screenname, params.get("group", ""), params.get("name", "")) | 215 addbuddy(account, screenname, params.get("group", ""), params.get("name", "")) |
216 else: | 216 else: |
217 goim(account, screenname) | 217 goim(account, screenname) |
218 | 218 |
219 def ymsgr(uri): | 219 def ymsgr(uri): |
221 match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri) | 221 match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri) |
222 if not match: | 222 if not match: |
223 print "Invalid ymsgr URI: %s" % uri | 223 print "Invalid ymsgr URI: %s" % uri |
224 return | 224 return |
225 | 225 |
226 command = urllib.unquote(match.group(1)) | 226 command = urllib.unquote_plus(match.group(1)) |
227 screenname = urllib.unquote(match.group(3)) | 227 screenname = urllib.unquote_plus(match.group(3)) |
228 paramstring = match.group(5) | 228 paramstring = match.group(5) |
229 params = {} | 229 params = {} |
230 if paramstring: | 230 if paramstring: |
231 for param in paramstring.split("&"): | 231 for param in paramstring.split("&"): |
232 key, value = extendlist(param.split("=", 1), 2, "") | 232 key, value = extendlist(param.split("=", 1), 2, "") |
233 params[key] = urllib.unquote(value) | 233 params[key] = urllib.unquote_plus(value) |
234 | 234 |
235 account = findaccount(protocol) | 235 account = findaccount(protocol) |
236 | 236 |
237 if command == "sendIM": | 237 if command.lower() == "sendIM": |
238 goim(account, screenname, params.get("m")) | 238 goim(account, screenname, params.get("m")) |
239 elif command == "chat": | 239 elif command.lower() == "chat": |
240 gochat(account, {"room": screenname}) | 240 gochat(account, {"room": screenname}) |
241 elif command == "addfriend": | 241 elif command.lower() == "addfriend": |
242 addbuddy(account, screenname) | 242 addbuddy(account, screenname) |
243 | 243 |
244 | 244 |
245 def main(argv=sys.argv): | 245 def main(argv=sys.argv): |
246 if len(argv) != 2: | 246 if len(argv) != 2: |