Mercurial > libervia-backend
comparison frontends/src/jp/common.py @ 2329:f15b428852a0
jp (common): fixed encoding issue in URLs
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 13 Jul 2017 21:45:26 +0200 |
parents | 07deebea71f3 |
children | ca14e1ced3b5 |
comparison
equal
deleted
inserted
replaced
2328:f9adda22a2e1 | 2329:f15b428852a0 |
---|---|
386 | 386 |
387 if not force_item and command not in ('new', 'last', 'current'): | 387 if not force_item and command not in ('new', 'last', 'current'): |
388 # we have probably an URL, we try to parse it | 388 # we have probably an URL, we try to parse it |
389 import urlparse | 389 import urlparse |
390 url = self.args.item | 390 url = self.args.item |
391 parsed_url = urlparse.urlsplit(url) | 391 parsed_url = urlparse.urlsplit(url.encode('utf-8')) |
392 if parsed_url.scheme.startswith('http'): | 392 if parsed_url.scheme.startswith('http'): |
393 self.disp(u"{} URL found, trying to find associated xmpp: URI".format(parsed_url.scheme.upper()),1) | 393 self.disp(u"{} URL found, trying to find associated xmpp: URI".format(parsed_url.scheme.upper()),1) |
394 # HTTP URL, we try to find xmpp: links | 394 # HTTP URL, we try to find xmpp: links |
395 try: | 395 try: |
396 from lxml import etree | 396 from lxml import etree |
416 if self.args.service or self.args.node: | 416 if self.args.service or self.args.node: |
417 self.parser.error(_(u"You can't use URI and --service or --node at the same time")) | 417 self.parser.error(_(u"You can't use URI and --service or --node at the same time")) |
418 | 418 |
419 self.disp(u"XMPP URI used: {}".format(url),2) | 419 self.disp(u"XMPP URI used: {}".format(url),2) |
420 # XXX: if we have not xmpp: URI here, we'll take the data as a file path | 420 # XXX: if we have not xmpp: URI here, we'll take the data as a file path |
421 pubsub_service = parsed_url.path | 421 pubsub_service = parsed_url.path.decode('utf-8') |
422 pubsub_data = urlparse.parse_qs(parsed_url.query) | 422 pubsub_data = urlparse.parse_qs(parsed_url.query) |
423 try: | 423 try: |
424 pubsub_node = pubsub_data['node'][0] | 424 pubsub_node = pubsub_data['node'][0].decode('utf-8') |
425 except KeyError: | 425 except KeyError: |
426 self.disp(u'No node found in xmpp: URI, can\'t retrieve item', error=True) | 426 self.disp(u'No node found in xmpp: URI, can\'t retrieve item', error=True) |
427 self.host.quit(1) | 427 self.host.quit(1) |
428 pubsub_item = pubsub_data.get('item',[None])[0] | 428 pubsub_item = pubsub_data.get('item',[None])[0].decode('utf-8') |
429 if pubsub_item is None and self.args.last_item: | 429 if pubsub_item is None and self.args.last_item: |
430 command = 'last' | 430 command = 'last' |
431 elif pubsub_item is not None: | 431 elif pubsub_item is not None: |
432 command = 'edit' # XXX: edit command is only used internaly, it similar to last, but with the item given in the URL | 432 command = 'edit' # XXX: edit command is only used internaly, it similar to last, but with the item given in the URL |
433 else: | 433 else: |