comparison src/server/server.py @ 1038:6b906b1f419a

pages: fixed XMPP URIs handling
author Goffi <goffi@goffi.org>
date Wed, 24 Jan 2018 09:57:57 +0100
parents dc6c8c4d8ff6
children 3d97c93561ff
comparison
equal deleted inserted replaced
1037:dc6c8c4d8ff6 1038:6b906b1f419a
188 # at this point we have a redirection URL in new, we can parse it 188 # at this point we have a redirection URL in new, we can parse it
189 new_url = urlparse.urlsplit(new.encode('utf-8')) 189 new_url = urlparse.urlsplit(new.encode('utf-8'))
190 190
191 # we handle the known URL schemes 191 # we handle the known URL schemes
192 if new_url.scheme == 'xmpp': 192 if new_url.scheme == 'xmpp':
193 # XMPP URI 193 location = LiberviaPage.getPagePathFromURI(new)
194 parsed_qs = urlparse.parse_qs(new_url.geturl()) 194 if location is None:
195 try: 195 log.warning(_(u"ignoring redirection, no page found to handle this URI: {uri}").format(uri=new))
196 item = parsed_qs['item'][0] 196 continue
197 if not item:
198 raise KeyError
199 except (IndexError, KeyError):
200 raise NotImplementedError(u"only item for PubSub URI is handled for the moment for url_redirections_dict")
201 location = "/blog/{profile}/{item}".format(
202 profile=quote(options['url_redirections_profile']),
203 item = urllib.quote_plus(item),
204 ).decode('utf-8')
205 request_data = self._getRequestData(location) 197 request_data = self._getRequestData(location)
206 if old: 198 if old:
207 self.inv_redirections[location] = old 199 self.inv_redirections[location] = old
208 200
209 elif new_url.scheme in ('', 'http', 'https'): 201 elif new_url.scheme in ('', 'http', 'https'):