def get_author(self): """Try to guess the author name. Use IP address as last resort.""" try: cookie = url_unquote(self.cookies.get("author", "")) except UnicodeError: cookie = None try: auth = url_unquote(self.environ.get('REMOTE_USER', "")) except UnicodeError: auth = None author = (self.form.get("author") or cookie or auth or self.remote_addr) return author
def get_author(self): """Try to guess the author name. Use IP address as last resort.""" try: cookie = werkzeug.url_unquote(self.cookies.get("author", "")) except UnicodeError: cookie = None try: auth = werkzeug.url_unquote(self.environ.get('REMOTE_USER', "")) except UnicodeError: auth = None author = (self.form.get("author") or cookie or auth or self.remote_addr) return author
def get_link_filename(self, _key, **values): link = url_unquote( self.link_to(_key, **values).lstrip('/'), ).encode('utf-8') if not link or link.endswith('/'): link += 'index.html' return os.path.join(self.default_output_folder, link)
def control(request, card, dwControlCode, inbuffer): hCard = Handle.query.get(card) impl = request.implementation inbuffer = json.loads(url_unquote(inbuffer)) opuid = logger.loginput(request, hCard.context, dwControlCode=dwControlCode, inbuffer=inbuffer) hresult, response = impl.SCardControl(hCard.val, dwControlCode, inbuffer) logger.logoutput(opuid, hresult, outbuffer=response) return render(request, hresult=hresult, outbuffer=response)
def listreaders(request, context, mszGroups): hContext = Context.query.get(context) impl = request.implementation mszGroups = json.loads(url_unquote(mszGroups)) opuid = logger.loginput(request, hContext, readergroup=mszGroups) hresult, readers = impl.SCardListReaders( hContext.val, mszGroups ) logger.logoutput(opuid, hresult, mszReaders=readers) return render(request, hresult=hresult, mszReaders=readers)
def test_quoting(): """URL quoting""" assert url_quote(u'\xf6\xe4\xfc') == '%C3%B6%C3%A4%C3%BC' assert url_unquote(url_quote(u'#%="\xf6')) == u'#%="\xf6' assert url_quote_plus('foo bar') == 'foo+bar' assert url_unquote_plus('foo+bar') == 'foo bar' assert url_encode({'a': None, 'b': 'foo bar'}) == 'b=foo+bar' assert url_fix(u'http://de.wikipedia.org/wiki/Elf (Begriffsklärung)') == \ 'http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29'
def transmit(request, card, dwProtocol, apdu): hCard = Handle.query.get(card) hContext = hCard.context impl = request.implementation apdu = json.loads(url_unquote(apdu)) opuid = logger.loginput(request, hContext, dwProtocol=dwProtocol, apdu=apdu) hresult, response = impl.SCardTransmit(hCard.val, dwProtocol, apdu) logger.logoutput(opuid, hresult, response=response) return render(request, hresult=hresult, response=response)
def unquote_link(self, link): """Unquotes some kinds of links. For example mailto:foo links are stripped and properly unquoted because the mails we write are in plain text and nobody is interested in URLs there. """ scheme, netloc, path = urlsplit(link)[:3] if scheme == 'mailto': return url_unquote(path) return link
def _file_to_title(self, filepath): _ = self._ if not filepath.startswith(self.repo_prefix): raise error.ForbiddenErr( _(u"Can't read or write outside of the pages repository")) name = filepath[len(self.repo_prefix):].strip('/') # Un-escape special windows filenames and dot files if name.startswith('_') and len(name) > 1: name = name[1:] if self.extension and name.endswith(self.extension): name = name[:-len(self.extension)] return werkzeug.url_unquote(name)
def connect(request, context, szReader, dwSharedMode, dwPreferredProtocols): hContext = Context.query.get(context) impl = request.implementation szReader = str(url_unquote(szReader)) opuid = logger.loginput(request, hContext, szReader=szReader, dwSharedMode=dwSharedMode, dwPreferredProtocols=dwPreferredProtocols) hresult, hCard, dwActiveProtocol = impl.SCardConnect( hContext.val, szReader, dwSharedMode, dwPreferredProtocols) after = datetime.now() hCard = Handle(hCard, hContext) logger.logoutput(opuid, hresult, hCard=hCard.uid, dwActiveProtocol=dwActiveProtocol, time=after) return render(request, hresult=hresult, hCard=hCard.uid, dwActiveProtocol=dwActiveProtocol)
def mercadopago_back_no_return(self, **post): """ Odoo, si usas el boton de pago desde una sale order o email, no manda una return url, desde website si y la almacenan en un valor que vuelve desde el agente de pago. Como no podemos mandar esta "return_url" para que vuelva, directamente usamos dos distintas y vovemos con una u otra """ _logger.info( 'Mercadopago: entering mecadopago_back with post data %s', pprint.pformat(post)) request.env['payment.transaction'].sudo().form_feedback( post, 'mercadopago') return werkzeug.utils.redirect(werkzeug.url_unquote( post.pop('return_url', '/')))
def setlang(): ''' Cambia el idioma ''' # si el idioma esta entre los permitidos y el usuario esta logueado se actualiza en la base de datos if g.lang in current_app.config["ALL_LANGS"] and current_user.is_authenticated(): current_user.set_lang(g.lang) usersdb.update_user({"_id":current_user.id,"lang":g.lang}) # si se puede se redirige a la pagina en la que se estaba if request.referrer: parts = url_unquote(request.referrer).split("/") if parts[0] in ("http:","https:"): parts = parts[3:] return redirect("/%s/%s" % (g.lang, "/".join(parts[1:]))) else: return redirect(url_for("index.home"))
def read_image(self, image): result = {'status': False, 'encoded_string': ""} url = False path = os.path.abspath(__file__ + "/../../") if image.startswith('https://') or image.startswith('http://'): request.urlretrieve(image, path + '1.png') image = path + '1.png' url = True file_name = werkzeug.url_unquote(image) try: with open(file_name, "rb") as image_file: result['encoded_string'] = base64.b64encode(image_file.read()) result['status'] = True except Exception as e: _logger.info("Exception %r", e) result['encoded_string'] = "Image Not Found" if url: os.remove(path + '1.png') return result
def getstatuschange(request, context, dwTimeout, rgReaderStates): hContext = Context.query.get(context) impl = request.implementation dwTimeout = unsigned_long(dwTimeout) rgReaderStates = json.loads(url_unquote(rgReaderStates)) ReaderStates = [] for readerstate in rgReaderStates: name = str(readerstate[0]) event = readerstate[1] res = name, event, try: atr = readerstate[2] res = name, event, atr except IndexError: pass ReaderStates.append(res) opuid = logger.loginput(request, hContext, dwTimeout=dwTimeout, rgReaderStates=ReaderStates) hresult, states = impl.SCardGetStatusChange( hContext.val, dwTimeout, ReaderStates ) logger.logoutput(opuid, hresult, rgReaderStates=states) return render(request, hresult=hresult, rgReaderStates=states)
def dbpedia_process(quoted): splitted_quoted = quoted.split(':') return werkzeug.url_unquote(splitted_quoted[1])
def get_link_filename(self, _key, **values): link = url_unquote(self.link_to(_key, **values).lstrip('/')).encode('utf-8') if not link or link.endswith('/'): link += 'index.html' return os.path.join(self.default_output_folder, link)
def _decode(self, qkey): return url_unquote(qkey)
def ogone_validation_form_feedback(self, **post): """ Feedback from 3d secure for a bank card validation """ request.env['payment.transaction'].sudo().form_feedback(post, 'ogone') return werkzeug.utils.redirect( werkzeug.url_unquote(post.pop('return_url', '/')))
def get_link_filename(self, _key, **values): link = url_unquote(self.link_to(_key, **values).lstrip("/")).encode("utf-8") if not link or link.endswith("/"): link += "index.html" return os.path.join(self.default_output_folder, link)
def ogone_validation_form_feedback(self, **post): """ Feedback from 3d secure for a bank card validation """ request.env['payment.transaction'].sudo().form_feedback(post, 'ogone') return werkzeug.utils.redirect(werkzeug.url_unquote(post.pop('return_url', '/')))