Example #1
0
 def test_quoting(self):
     self.assert_strict_equal(urls.url_quote(u'\xf6\xe4\xfc'),
                              '%C3%B6%C3%A4%C3%BC')
     self.assert_strict_equal(urls.url_unquote(urls.url_quote(u'#%="\xf6')),
                              u'#%="\xf6')
     self.assert_strict_equal(urls.url_quote_plus('foo bar'), 'foo+bar')
     self.assert_strict_equal(urls.url_unquote_plus('foo+bar'), u'foo bar')
     self.assert_strict_equal(urls.url_quote_plus('foo+bar'), 'foo%2Bbar')
     self.assert_strict_equal(urls.url_unquote_plus('foo%2Bbar'),
                              u'foo+bar')
     self.assert_strict_equal(
         urls.url_encode({
             b'a': None,
             b'b': b'foo bar'
         }), 'b=foo+bar')
     self.assert_strict_equal(
         urls.url_encode({
             u'a': None,
             u'b': u'foo bar'
         }), 'b=foo+bar')
     self.assert_strict_equal(
         urls.url_fix(
             u'http://de.wikipedia.org/wiki/Elf (Begriffsklärung)'),
         'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)')
     self.assert_strict_equal(urls.url_quote_plus(42), '42')
     self.assert_strict_equal(urls.url_quote(b'\xff'), '%FF')
def encode_query_string(event):
    params = event.get(u"multiValueQueryStringParameters")
    if not params:
        params = event.get(u"queryStringParameters")
    if not params:
        params = ""
    if is_alb_event(event):
        params = MultiDict((url_unquote_plus(k), url_unquote_plus(v))
                           for k, v in iter_multi_items(params))
    return url_encode(params)
Example #3
0
 def test_quoting(self):
     self.assert_strict_equal(urls.url_quote(u'\xf6\xe4\xfc'), '%C3%B6%C3%A4%C3%BC')
     self.assert_strict_equal(urls.url_unquote(urls.url_quote(u'#%="\xf6')), u'#%="\xf6')
     self.assert_strict_equal(urls.url_quote_plus('foo bar'), 'foo+bar')
     self.assert_strict_equal(urls.url_unquote_plus('foo+bar'), u'foo bar')
     self.assert_strict_equal(urls.url_quote_plus('foo+bar'), 'foo%2Bbar')
     self.assert_strict_equal(urls.url_unquote_plus('foo%2Bbar'), u'foo+bar')
     self.assert_strict_equal(urls.url_encode({b'a': None, b'b': b'foo bar'}), 'b=foo+bar')
     self.assert_strict_equal(urls.url_encode({u'a': None, u'b': u'foo bar'}), 'b=foo+bar')
     self.assert_strict_equal(urls.url_fix(u'http://de.wikipedia.org/wiki/Elf (Begriffsklärung)'),
            'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)')
     self.assert_strict_equal(urls.url_quote_plus(42), '42')
     self.assert_strict_equal(urls.url_quote(b'\xff'), '%FF')
Example #4
0
def admin_edit(url):
    title = None
    body = ""
    if url:
        try:
            title = url_unquote_plus(url)
            f = open('posts/' + urlsafe_b64encode(title))
        except:
            pass
        else:
            title = url_unquote_plus(url)
            body = f.read()
            f.close()
    return render_template('admin_posts.html', title=title, body=body)
Example #5
0
def test_quoting():
    strict_eq(urls.url_quote(u"\xf6\xe4\xfc"), "%C3%B6%C3%A4%C3%BC")
    strict_eq(urls.url_unquote(urls.url_quote(u'#%="\xf6')), u'#%="\xf6')
    strict_eq(urls.url_quote_plus("foo bar"), "foo+bar")
    strict_eq(urls.url_unquote_plus("foo+bar"), u"foo bar")
    strict_eq(urls.url_quote_plus("foo+bar"), "foo%2Bbar")
    strict_eq(urls.url_unquote_plus("foo%2Bbar"), u"foo+bar")
    strict_eq(urls.url_encode({b"a": None, b"b": b"foo bar"}), "b=foo+bar")
    strict_eq(urls.url_encode({u"a": None, u"b": u"foo bar"}), "b=foo+bar")
    strict_eq(
        urls.url_fix(u"http://de.wikipedia.org/wiki/Elf (Begriffsklärung)"),
        "http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)",
    )
    strict_eq(urls.url_quote_plus(42), "42")
    strict_eq(urls.url_quote(b"\xff"), "%FF")
Example #6
0
def test_quoting():
    assert urls.url_quote("\xf6\xe4\xfc") == "%C3%B6%C3%A4%C3%BC"
    assert urls.url_unquote(urls.url_quote('#%="\xf6')) == '#%="\xf6'
    assert urls.url_quote_plus("foo bar") == "foo+bar"
    assert urls.url_unquote_plus("foo+bar") == "foo bar"
    assert urls.url_quote_plus("foo+bar") == "foo%2Bbar"
    assert urls.url_unquote_plus("foo%2Bbar") == "foo+bar"
    assert urls.url_encode({b"a": None, b"b": b"foo bar"}) == "b=foo+bar"
    assert urls.url_encode({"a": None, "b": "foo bar"}) == "b=foo+bar"
    assert (
        urls.url_fix("http://de.wikipedia.org/wiki/Elf (Begriffsklärung)")
        == "http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)"
    )
    assert urls.url_quote_plus(42) == "42"
    assert urls.url_quote(b"\xff") == "%FF"
Example #7
0
def show_password(password_key):
    password_key = url_unquote_plus(password_key)
    password = get_password(password_key)
    if not password:
        return render_template('expired.html'), 404

    return render_template('password.html', password=password)
Example #8
0
def show_password(password_key):
    password_key = url_unquote_plus(password_key)
    password = get_password(password_key)
    if not password:
        abort(404)

    return render_template('password.html', password=password)
Example #9
0
 def _get_return_url(self, **post):
     """ Extract the return URL from the data coming from paypal. """
     return_url = post.pop('return_url', '')
     if not return_url:
         custom = json.loads(urls.url_unquote_plus(post.pop('custom', False) or post.pop('cm', False) or '{}'))
         return_url = custom.get('return_url', '/')
     return return_url
Example #10
0
File: main.py Project: 1806933/odoo
 def _get_return_url(self, **post):
     """ Extract the return URL from the data coming from paypal. """
     return_url = post.pop('return_url', '')
     if not return_url:
         custom = json.loads(urls.url_unquote_plus(post.pop('custom', False) or post.pop('cm', False) or '{}'))
         return_url = custom.get('return_url', '/')
     return return_url
Example #11
0
def preview_password(password_key):
    password_key = url_unquote_plus(password_key)
    if not password_exists(password_key):
        abort(404)
    if not request_is_valid(request):
        abort(404)
    return render_template('preview.html')
Example #12
0
def zset_edit_score(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    maps = {request.form.get("name"): request.form.get("value", type=float)}
    conn.zadd(ori_key, maps)
    return jsonify({"code": 0})
Example #13
0
    def _buckaroo_generate_digital_sign(self, values, incoming=True):
        """ Generate the shasign for incoming or outgoing communications.

        :param dict values: The values used to generate the signature
        :param bool incoming: Whether the signature must be generate for an incoming (Buckaroo to
                              Odoo) or outgoing (Odoo to Buckaroo) communication.
        :return: The shasign
        :rtype: str
        """
        if incoming:
            # Remove the signature from the values used to check the signature
            for key in values.keys():
                if key.upper() == 'BRQ_SIGNATURE':  # Keys are case-insensitive
                    del values[key]
                    break
            # Incoming communication values must be URL-decoded before checking the signature
            items = [(k, urls.url_unquote_plus(v)) for k, v in values.items()]
        else:
            # Only use items whose key starts with 'add_', 'brq_', or 'cust_' (case insensitive)
            items = [
                (k, v) for k, v in values.items()
                if any(k.upper().startswith(key_prefix) for key_prefix in ('ADD_', 'BRQ_', 'CUST_'))
            ]
        # Sort parameters by lower-cased key. Not upper- because ord('A') < ord('_') < ord('a').
        sorted_items = sorted(items, key=lambda pair: pair[0].lower())
        # Build the signing string by concatenating all parameters
        sign_string = ''.join(f'{k}={v or ""}' for k, v in sorted_items)
        # Append the pre-shared secret key to the signing string
        sign_string += self.buckaroo_secret_key
        # Calculate the SHA-1 hash over the signing string
        return sha1(sign_string.encode('utf-8')).hexdigest()
Example #14
0
 def ogone_form_feedback(self, **post):
     """ Ogone contacts using GET, at least for accept """
     _logger.info('Ogone: entering form_feedback with post data %s',
                  pprint.pformat(post))  # debug
     request.env['payment.transaction'].sudo().form_feedback(post, 'ogone')
     return werkzeug.utils.redirect(
         url_unquote_plus(post.pop('return_url', '/')))
Example #15
0
def list_edit_value(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    index = request.form.get("name", type=int)
    conn.lset(ori_key, index, request.form.get("value"))
    return jsonify({"code": 0})
Example #16
0
 def test_quoting(self):
     assert urls.url_quote(u'\xf6\xe4\xfc') == '%C3%B6%C3%A4%C3%BC'
     assert urls.url_unquote(urls.url_quote(u'#%="\xf6')) == u'#%="\xf6'
     assert urls.url_quote_plus('foo bar') == 'foo+bar'
     assert urls.url_unquote_plus('foo+bar') == 'foo bar'
     assert urls.url_encode({'a': None, 'b': 'foo bar'}) == 'b=foo+bar'
     assert urls.url_fix(u'http://de.wikipedia.org/wiki/Elf (Begriffsklärung)') == \
            'http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29'
Example #17
0
def hash_rem_value(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    conn.hdel(ori_key, request.form["index"])
    return jsonify(
        {"code": 0, "data": url_for("redisboard.key_detail", db=db, key=key)}
    )
Example #18
0
 def test_quoting(self):
     assert urls.url_quote(u'\xf6\xe4\xfc') == '%C3%B6%C3%A4%C3%BC'
     assert urls.url_unquote(urls.url_quote(u'#%="\xf6')) == u'#%="\xf6'
     assert urls.url_quote_plus('foo bar') == 'foo+bar'
     assert urls.url_unquote_plus('foo+bar') == 'foo bar'
     assert urls.url_encode({'a': None, 'b': 'foo bar'}) == 'b=foo+bar'
     assert urls.url_fix(u'http://de.wikipedia.org/wiki/Elf (Begriffsklärung)') == \
            'http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29'
Example #19
0
def admin_edit(url):
    title = None
    body = ""
    if url:
        title = url_unquote_plus(url)
        if db.exists(title):
            body = db.get(title)
    return render_template("admin_posts.html", title=title, body=body)
Example #20
0
def post(url):
    if not url:
        return redirect(url_for("post", url="about"))

    title = url_unquote_plus(url)
    if db.exists(title):
        return render_template("post.html", title=title, body=db.get(title), url=url, log=db.log(title, limit=50))
    else:
        return redirect(url_for("admin_edit", url=url))
Example #21
0
def show_password(password_key):
    if not request_is_valid(request):
        abort(404)
    password_key = url_unquote_plus(password_key)
    password = get_password(password_key)
    if not password:
        abort(404)

    return render_template('password.html', password=password)
Example #22
0
def list_rem_value(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    count = request.form.get("count", type=int, default=1)
    conn.lrem(ori_key, count, request.form["value"])
    return jsonify(
        {"code": 0, "data": url_for("redisboard.key_detail", db=db, key=key)}
    )
Example #23
0
def key_detail(db, key):
    conn = server.connection
    key = url_unquote_plus(key)
    if request.method == "POST":
        conn.set(key, request.form["value"])
    key_details = _get_key_details(conn, db, key)
    return render_template(
        f"keydetail/{key_details['type']}.html", key_details=key_details, db=db
    )
Example #24
0
def show_password(password_key):
    password_key = url_unquote_plus(password_key)
    contentStr = get_password(password_key)
    if not contentStr:
        abort(404)
    contentObj = json.loads(contentStr)
    password = contentObj['password']
    console_log = 'Email sent from ' + gmail_email + ' to ' + contentObj[
        'email']
    return render_template('password.html', password=password, log=console_log)
Example #25
0
def zset_add_value(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    conn.zadd(
        ori_key, {request.form.get("member"): request.form.get("score", type=float)}
    )
    return jsonify(
        {"code": 0, "data": url_for("redisboard.key_detail", db=db, key=key)}
    )
Example #26
0
 def test_quoting(self):
     assert urls.url_quote(u"\xf6\xe4\xfc") == "%C3%B6%C3%A4%C3%BC"
     assert urls.url_unquote(urls.url_quote(u'#%="\xf6')) == u'#%="\xf6'
     assert urls.url_quote_plus("foo bar") == "foo+bar"
     assert urls.url_unquote_plus("foo+bar") == "foo bar"
     assert urls.url_encode({"a": None, "b": "foo bar"}) == "b=foo+bar"
     assert (
         urls.url_fix(u"http://de.wikipedia.org/wiki/Elf (Begriffsklärung)")
         == "http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29"
     )
Example #27
0
def set_rem_value(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    value = request.form.get("value", "")
    value = [item.strip() for item in value.split(",")]
    conn.srem(ori_key, *value)
    return jsonify(
        {"code": 0, "data": url_for("redisboard.key_detail", db=db, key=key)}
    )
Example #28
0
def index():
    if empty(request.args.get('t')):
        return render_template('set_password.html')
    else:
        password_key = request.args.get('t')
        password_key = url_unquote_plus(password_key)
        if not password_exists(password_key):
            abort(404)

    return render_template('preview.html')
Example #29
0
    def unserialize(cls, string, secret_key):
        """Load the secure cookie from a serialized string.

        :param string: the cookie value to unserialize.
        :param secret_key: the secret key used to serialize the cookie.
        :return: a new :class:`SecureCookie`.
        """
        # explicitly convert it into a bytestring because python 2.6
        # no longer performs an implicit string conversion on hmac
        secret_key = str(secret_key)
        if isinstance(string, unicode):
            string = string.encode('utf-8', 'replace')
        try:
            base64_hash, data = string.split('?', 1)
        except (ValueError, IndexError):
            items = ()
        else:
            items = {}
            mac = hmac(secret_key, None, cls.hash_method)
            for item in data.split('&'):
                mac.update('|' + item)
                if not '=' in item:
                    items = None
                    break
                key, value = item.split('=', 1)
                # try to make the key a string
                key = url_unquote_plus(key)
                try:
                    key = str(key)
                except UnicodeError:
                    pass
                items[key] = value

            # no parsing error and the mac looks okay, we can now
            # sercurely unpickle our cookie.
            try:
                client_hash = base64_hash.decode('base64')
            except Exception:
                items = client_hash = None
            if items is not None and safe_str_cmp(client_hash, mac.digest()):
                try:
                    for key, value in items.iteritems():
                        items[key] = cls.unquote(value)
                except UnquoteError:
                    items = ()
                else:
                    if '_expires' in items:
                        if time() > items['_expires']:
                            items = ()
                        else:
                            del items['_expires']
            else:
                items = ()
        return cls(items, secret_key, False)
Example #30
0
def set_add_value(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    value = request.form.get("value", "")
    value = [item.strip() for item in value.split(",")]
    result = conn.sadd(ori_key, *value)
    # TODO response how many successed operate
    return jsonify(
        {"code": 0, "data": url_for("redisboard.key_detail", db=db, key=key)}
    )
Example #31
0
def get_password_api(password_key):
    password_key = url_unquote_plus(password_key)
    password = get_password(password_key)
    if not password:
        return not_found_api()

    base_url = make_base_url()

    data = {'password': password}

    return jsonify(data)
Example #32
0
 def PATCH(self, request_id, url):
     url = url_unquote_plus(url)
     self.req = ndb.Key('Request', request_id).get()
     if self.req is None:
         self.abort(404, 'No such request')
     for c in self.req.content_suggestions:
         if url == c.url:
             c.votes += 1
             self.req.put()
             return self.redirect()
     self.abort(404, 'No such content suggestion')
Example #33
0
    def unserialize(cls, string, secret_key):
        """Load the secure cookie from a serialized string.

        :param string: the cookie value to unserialize.
        :param secret_key: the secret key used to serialize the cookie.
        :return: a new :class:`SecureCookie`.
        """
        # explicitly convert it into a bytestring because python 2.6
        # no longer performs an implicit string conversion on hmac
        secret_key = str(secret_key)
        if isinstance(string, unicode):
            string = string.encode('utf-8', 'replace')
        try:
            base64_hash, data = string.split('?', 1)
        except (ValueError, IndexError):
            items = ()
        else:
            items = {}
            mac = hmac(secret_key, None, cls.hash_method)
            for item in data.split('&'):
                mac.update('|' + item)
                if not '=' in item:
                    items = None
                    break
                key, value = item.split('=', 1)
                # try to make the key a string
                key = url_unquote_plus(key)
                try:
                    key = str(key)
                except UnicodeError:
                    pass
                items[key] = value

            # no parsing error and the mac looks okay, we can now
            # sercurely unpickle our cookie.
            try:
                client_hash = base64_hash.decode('base64')
            except Exception:
                items = client_hash = None
            if items is not None and safe_str_cmp(client_hash, mac.digest()):
                try:
                    for key, value in items.iteritems():
                        items[key] = cls.unquote(value)
                except UnquoteError:
                    items = ()
                else:
                    if '_expires' in items:
                        if time() > items['_expires']:
                            items = ()
                        else:
                            del items['_expires']
            else:
                items = ()
        return cls(items, secret_key, False)
Example #34
0
def preview(token: str):
    """just check if the token is valid here
    """
    try:
        valid, metadata = token_handler.is_token_valid(url_unquote_plus(token))
        return {
            'valid': valid,
            'meta': metadata,
        }
    except InvalidToken:
        return make_error('Invalid token')
Example #35
0
    def unserialize(cls, string, secret_key):
        """Load the secure cookie from a serialized string.

        :param string: the cookie value to unserialize.
        :param secret_key: the secret key used to serialize the cookie.
        :return: a new :class:`SecureCookie`.
        """
        if isinstance(string, unicode):
            string = string.encode("utf-8", "replace")
        if isinstance(secret_key, unicode):
            secret_key = secret_key.encode("utf-8", "replace")
        try:
            base64_hash, data = string.split("?", 1)
        except (ValueError, IndexError):
            items = ()
        else:
            items = {}
            mac = hmac(secret_key, None, cls.hash_method)
            for item in data.split("&"):
                mac.update("|" + item)
                if not "=" in item:
                    items = None
                    break
                key, value = item.split("=", 1)
                # try to make the key a string
                key = url_unquote_plus(key)
                try:
                    key = str(key)
                except UnicodeError:
                    pass
                items[key] = value

            # no parsing error and the mac looks okay, we can now
            # sercurely unpickle our cookie.
            try:
                client_hash = base64_hash.decode("base64")
            except Exception:
                items = client_hash = None
            if items is not None and safe_str_cmp(client_hash, mac.digest()):
                try:
                    for key, value in items.iteritems():
                        items[key] = cls.unquote(value)
                except UnquoteError:
                    items = ()
                else:
                    if "_expires" in items:
                        if time() > items["_expires"]:
                            items = ()
                        else:
                            del items["_expires"]
            else:
                items = ()
        return cls(items, secret_key, False)
    def unserialize(cls, string, secret_key):
        """Load the secure cookie from a serialized string.

        :param string: the cookie value to unserialize.
        :param secret_key: the secret key used to serialize the cookie.
        :return: a new :class:`SecureCookie`.
        """
        if isinstance(string, text_type):
            string = string.encode('utf-8', 'replace')
        if isinstance(secret_key, text_type):
            secret_key = secret_key.encode('utf-8', 'replace')
        try:
            base64_hash, data = string.split(b'?', 1)
        except (ValueError, IndexError):
            items = ()
        else:
            items = {}
            mac = hmac(secret_key, None, cls.hash_method)
            for item in data.split(b'&'):
                mac.update(b'|' + item)
                if not b'=' in item:
                    items = None
                    break
                key, value = item.split(b'=', 1)
                # try to make the key a string
                key = url_unquote_plus(key.decode('ascii'))
                try:
                    key = to_native(key)
                except UnicodeError:
                    pass
                items[key] = value

            # no parsing error and the mac looks okay, we can now
            # sercurely unpickle our cookie.
            try:
                client_hash = base64.b64decode(base64_hash)
            except TypeError:
                items = client_hash = None
            if items is not None and safe_str_cmp(client_hash, mac.digest()):
                try:
                    for key, value in iteritems(items):
                        items[key] = cls.unquote(value)
                except UnquoteError:
                    items = ()
                else:
                    if '_expires' in items:
                        if time() > items['_expires']:
                            items = ()
                        else:
                            del items['_expires']
            else:
                items = ()
        return cls(items, secret_key, False)
Example #37
0
def key_rename(db: int, key: str) -> Response:
    conn = server.connection
    conn.execute_command("SELECT", db)
    key = url_unquote_plus(key)
    new_name = request.form["keyname"]
    conn.rename(key, new_name)
    return jsonify({
        "code":
        0,
        "data":
        url_for("redisboard.key_detail", db=db, key=url_quote_plus(new_name)),
    })
Example #38
0
def list_add_value(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    position = request.form.get("position", type=int)
    if position == 0:
        conn.lpush(ori_key, request.form["value"])
    elif position == -1:
        conn.rpush(ori_key, request.form["value"])
    return jsonify(
        {"code": 0, "data": url_for("redisboard.key_detail", db=db, key=key)}
    )
Example #39
0
def key_set_ttl(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    ttl = request.form.get("ttl", type=int)
    if ttl <= 0:
        conn.persist(ori_key)
    else:
        conn.expire(ori_key, ttl)
    return jsonify(
        {"code": 0, "data": url_for("redisboard.key_detail", db=db, key=key)}
    )
Example #40
0
def post(url):
    if not url:
        return redirect(url_for('post', url='about'))
    try:
        title = url_unquote_plus(url)
        f = open('posts/' + urlsafe_b64encode(title))
    except:
        return redirect(url_for('admin_edit', url=url))
    else:
        body = f.read()
        f.close()
        return render_template('post.html', title=title, body=body, url=url)
Example #41
0
def hash_add_value(db, key):
    conn = server.connection
    conn.execute_command("SELECT", db)
    ori_key = url_unquote_plus(key)
    index = request.form.get("index", "")
    exists = conn.hexists(ori_key, index)
    if exists:
        return jsonify({"code": 1, "error": "can`t add value to an exist key!"})
    else:
        conn.hset(ori_key, index, request.form.get("value"))
    return jsonify(
        {"code": 0, "data": url_for("redisboard.key_detail", db=db, key=key)}
    )
Example #42
0
File: main.py Project: 1806933/odoo
    def _parse_pdt_response(self, response):
        """ Parse a text response for a PDT verification.

            :param response str: text response, structured in the following way:
                STATUS\nkey1=value1\nkey2=value2...\n
             or STATUS\nError message...\n
            :rtype tuple(str, dict)
            :return: tuple containing the STATUS str and the key/value pairs
                     parsed as a dict
        """
        lines = [line for line in response.split('\n') if line]
        status = lines.pop(0)

        pdt_post = {}
        for line in lines:
            split = line.split('=', 1)
            if len(split) == 2:
                pdt_post[split[0]] = urls.url_unquote_plus(split[1]).decode('utf8')
            else:
                _logger.warning('Paypal: error processing pdt response: %s', line)

        return status, pdt_post
Example #43
0
    def _buckaroo_generate_digital_sign(self, inout, values):
        """ Generate the shasign for incoming or outgoing communications.

        :param browse acquirer: the payment.acquirer browse record. It should
                                have a shakey in shaky out
        :param string inout: 'in' (odoo contacting buckaroo) or 'out' (buckaroo
                             contacting odoo).
        :param dict values: transaction values

        :return string: shasign
        """
        assert inout in ('in', 'out')
        assert self.provider == 'buckaroo'

        keys = "add_returndata Brq_amount Brq_culture Brq_currency Brq_invoicenumber Brq_return Brq_returncancel Brq_returnerror Brq_returnreject brq_test Brq_websitekey".split()

        def get_value(key):
            if values.get(key):
                return values[key]
            return ''

        values = dict(values or {})

        if inout == 'out':
            for key in list(values):
                # case insensitive keys
                if key.upper() == 'BRQ_SIGNATURE':
                    del values[key]
                    break

            items = sorted(values.items(), key=lambda pair: pair[0].lower())
            sign = ''.join('%s=%s' % (k, urls.url_unquote_plus(v)) for k, v in items)
        else:
            sign = ''.join('%s=%s' % (k, get_value(k)) for k in keys)
        # Add the pre-shared secret key at the end of the signature
        sign = sign + self.brq_secretkey
        shasign = sha1(sign.encode('utf-8')).hexdigest()
        return shasign
Example #44
0
def test_url_unquote_plus_unicode():
    """Make sure that URL unquote plus accepts unicode."""
    # was broken in 0.6
    assert url_unquote_plus(u'\x6d') == u'\x6d'
    assert type(url_unquote_plus(u'\x6d')) is unicode
Example #45
0
 def to_python(self, value):
     return url_unquote_plus(value)
Example #46
0
 def ogone_form_feedback(self, **post):
     """ Ogone contacts using GET, at least for accept """
     _logger.info('Ogone: entering form_feedback with post data %s', pprint.pformat(post))  # debug
     request.env['payment.transaction'].sudo().form_feedback(post, 'ogone')
     return werkzeug.utils.redirect(url_unquote_plus(post.pop('return_url', '/')))
Example #47
0
 def test_url_unquote_plus_unicode(self):
     # was broken in 0.6
     self.assert_strict_equal(urls.url_unquote_plus(u'\x6d'), u'\x6d')
     self.assert_is(type(urls.url_unquote_plus(u'\x6d')), text_type)
Example #48
0
def test_url_unquote_plus_unicode():
    # was broken in 0.6
    strict_eq(urls.url_unquote_plus(u'\x6d'), u'\x6d')
    assert type(urls.url_unquote_plus(u'\x6d')) is text_type
Example #49
0
 def test_url_unquote_plus_unicode(self):
     # was broken in 0.6
     assert urls.url_unquote_plus(u"\x6d") == u"\x6d"
     assert type(urls.url_unquote_plus(u"\x6d")) is unicode