Example #1
0
    def _decode_filter_option(self, query):
        filter_option = query.dictionary.get('_$filter')
        if filter_option:
            for part in filter_option['parts']:
                # decode all Edm types, even those which were not encoded
                decoded_value = decode_string(part['operand'])
                part['operand'] = decoded_value

                # decode functions' parameters
                params = part.get('params', None)
                if params:
                    for i, param in enumerate(params):
                        params[i] = decode_string(param)
Example #2
0
    def _decode_accessible_keys(self, query):
        """Decode accessible keys that identify a single entity within an entity set.

        For example: Customers(CustomerID='%C3%AF%C2%B6') -> Customers(CustomerID='ï¶')
        """
        accessible_keys = query.dictionary.get('accessible_keys', None)
        if accessible_keys:
            for key, value in accessible_keys.items():
                accessible_keys[key] = decode_string(value)
Example #3
0
def test_string_decoding():
    assert decode_string('') == ''
    assert decode_string(r'%27%27%27%27') == '\'\''
    assert decode_string(r'%27%27') == '\''

    assert decode_string(r'asd%2B%2Basd') == 'asd++asd'
    assert decode_string(r'asd%27%27asd%27%27%27%27') == 'asd\'asd\'\''
    assert decode_string(r'asd%26asd') == 'asd&asd'

    assert decode_string(r'%21%2F%2F') == '!//'
    assert decode_string(r'%C2%AC%C2%B3h%C3%92%C2%90%C3%9A') == '¬³hÒ\x90Ú'
Example #4
0
 def _decode_search_option(self, query):
     search_option = query.dictionary.get('_search')
     if search_option:
         decoded_value = decode_string(search_option)
         query.dictionary['_search'] = decoded_value
Example #5
0
def test_double_decoding():
    assert decode_string('2e%2B2d') == '2e+2d'
    assert decode_string('0e%2B2d') == '0e+2d'

    assert decode_string(
        '2.286428418907951e%2B39d') == '2.286428418907951e+39d'