|
20 | 20 |
|
21 | 21 | from lib.core.data import conf |
22 | 22 |
|
23 | | -def base64decode(string): |
24 | | - return string.decode("base64") |
| 23 | +def base64decode(value): |
| 24 | + return value.decode("base64") |
25 | 25 |
|
26 | | -def base64encode(string): |
27 | | - return string.encode("base64")[:-1].replace("\n", "") |
| 26 | +def base64encode(value): |
| 27 | + return value.encode("base64")[:-1].replace("\n", "") |
28 | 28 |
|
29 | | -def base64pickle(string): |
30 | | - return base64encode(pickle.dumps(string)) |
| 29 | +def base64pickle(value): |
| 30 | + return base64encode(pickle.dumps(value)) |
31 | 31 |
|
32 | | -def base64unpickle(string): |
33 | | - return pickle.loads(base64decode(string)) |
| 32 | +def base64unpickle(value): |
| 33 | + return pickle.loads(base64decode(value)) |
34 | 34 |
|
35 | | -def hexdecode(string): |
36 | | - string = string.lower() |
| 35 | +def hexdecode(value): |
| 36 | + value = value.lower() |
37 | 37 |
|
38 | | - if string.startswith("0x"): |
39 | | - string = string[2:] |
| 38 | + if value.startswith("0x"): |
| 39 | + value = value[2:] |
40 | 40 |
|
41 | | - return string.decode("hex") |
| 41 | + return value.decode("hex") |
42 | 42 |
|
43 | | -def hexencode(string): |
44 | | - return string.encode("hex") |
| 43 | +def hexencode(value): |
| 44 | + return value.encode("hex") |
45 | 45 |
|
46 | | -def md5hash(string): |
| 46 | +def md5hash(value): |
47 | 47 | if sys.modules.has_key('hashlib'): |
48 | | - return hashlib.md5(string).hexdigest() |
| 48 | + return hashlib.md5(value).hexdigest() |
49 | 49 | else: |
50 | | - return md5.new(string).hexdigest() |
| 50 | + return md5.new(value).hexdigest() |
51 | 51 |
|
52 | | -def orddecode(string): |
53 | | - packedString = struct.pack("!"+"I" * len(string), *string) |
| 52 | +def orddecode(value): |
| 53 | + packedString = struct.pack("!"+"I" * len(value), *value) |
54 | 54 | return "".join([chr(char) for char in struct.unpack("!"+"I"*(len(packedString)/4), packedString)]) |
55 | 55 |
|
56 | | -def ordencode(string): |
57 | | - return tuple([ord(char) for char in string]) |
| 56 | +def ordencode(value): |
| 57 | + return tuple([ord(char) for char in value]) |
58 | 58 |
|
59 | | -def sha1hash(string): |
| 59 | +def sha1hash(value): |
60 | 60 | if sys.modules.has_key('hashlib'): |
61 | | - return hashlib.sha1(string).hexdigest() |
| 61 | + return hashlib.sha1(value).hexdigest() |
62 | 62 | else: |
63 | | - return sha.new(string).hexdigest() |
| 63 | + return sha.new(value).hexdigest() |
64 | 64 |
|
65 | | -def urldecode(string): |
| 65 | +def urldecode(value): |
66 | 66 | result = None |
67 | 67 |
|
68 | | - if string: |
69 | | - result = urllib.unquote_plus(string) |
| 68 | + if value: |
| 69 | + result = urllib.unquote_plus(value) |
70 | 70 |
|
71 | 71 | return result |
72 | 72 |
|
73 | | -def urlencode(string, safe=":/?%&=", convall=False): |
| 73 | +def urlencode(value, safe=":/?%&=", convall=False): |
74 | 74 | if conf.direct or "POSTxml" in conf.paramDict: |
75 | | - return string |
| 75 | + return value |
76 | 76 |
|
77 | 77 | result = None |
78 | 78 |
|
79 | | - if string is None: |
| 79 | + if value is None: |
80 | 80 | return result |
81 | 81 |
|
82 | 82 | if convall: |
83 | | - result = urllib.quote(utf8encode(string)) # Reference: http://old.nabble.com/Re:-Problem:-neither-urllib2.quote-nor-urllib.quote-encode-the--unicode-strings-arguments-p19823144.html |
| 83 | + result = urllib.quote(utf8encode(value)) # Reference: http://old.nabble.com/Re:-Problem:-neither-urllib2.quote-nor-urllib.quote-encode-the--unicode-strings-arguments-p19823144.html |
84 | 84 | else: |
85 | | - result = urllib.quote(utf8encode(string), safe) |
| 85 | + result = urllib.quote(utf8encode(value), safe) |
86 | 86 |
|
87 | 87 | return result |
88 | 88 |
|
89 | | -def utf8encode(string): |
90 | | - return string.encode("utf-8") |
| 89 | +def utf8encode(value): |
| 90 | + return value.encode("utf-8") |
91 | 91 |
|
92 | | -def utf8decode(string): |
93 | | - return string.decode("utf-8") |
| 92 | +def utf8decode(value): |
| 93 | + return value.decode("utf-8") |
94 | 94 |
|
95 | | -def htmlescape(string): |
96 | | - return string.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''').replace(' ', ' ') |
| 95 | +def htmlescape(value): |
| 96 | + return value.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''').replace(' ', ' ') |
97 | 97 |
|
98 | | -def htmlunescape(string): |
99 | | - return string.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace(''', "'").replace(' ', ' ') |
| 98 | +def htmlunescape(value): |
| 99 | + return value.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace(''', "'").replace(' ', ' ') |
0 commit comments