Skip to content

Commit 2440783

Browse files
committed
update urlclean.mixPayload
1 parent 9eee967 commit 2440783

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

docs/urlclean.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ pathSplit
7474
mixPayload
7575
----------
7676

77-
.. Method:: Method mixPayload(url, payloads, scope=[])
77+
.. Method:: Method mixPayload(url, payloads, scope=[], append=True)
7878

7979
* **payloads** - [payload list]
8080
* **scope** - [path, params, query, fragment], Default By **All**
81+
* **append** - append payload for params/query/fragment, Default is **False**
8182

8283
::
8384

@@ -91,3 +92,11 @@ mixPayload
9192
'https://www.example.com/path/index;params?a=1&b=-Symbo1-&b=2#fragment',
9293
'https://www.example.com/path/index;params?a=1&b=3&c=-Symbo1-#fragment']
9394

95+
# use append:
96+
In[4]: mixPayload(url, payloads, ['query', 'params', 'fragement'], append=True)
97+
Out[4]: ['https://www.example.com/path/index;params?a=1&c=3-symbo1-&b=2#fragment',
98+
'https://www.example.com/path/index;params-symbo1-?a=1&b=2&c=3#fragment',
99+
'https://www.example.com/path/index;params?a=1&b=2&c=3#fragment-symbo1-',
100+
'https://www.example.com/path/index;params?a=1&c=3&b=2-symbo1-#fragment',
101+
'https://www.example.com/path/index;params?a=1-symbo1-&c=3&b=2#fragment']
102+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
long_description = fh.read()
88

99
setup(name="wsltools",
10-
version="0.2.2",
10+
version="0.2.3",
1111
description="Web Scan Lazy Tools",
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",

wsltools/urlclean.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def mixPayload(url, payloads, scope=[], append=False):
155155
:param url: Generic URL.
156156
:param payloads: Payloads list
157157
:param scope: [optional] list, e.g. [params, path, query, fragment]
158-
:param append: append payload for query and fragment, default is replace
158+
:param append: append payload for params/query/fragment, default is replace
159159
:return: list
160160
'''
161161

@@ -171,7 +171,10 @@ def mixPayload(url, payloads, scope=[], append=False):
171171

172172
for p in payloads:
173173
if (not scope or 'params' in scope) and u.params:
174-
result.add(urlunparse([u.scheme, u.netloc, u.path, p, u.query, u.fragment]))
174+
if append:
175+
result.add(urlunparse([u.scheme, u.netloc, u.path, u.params + p, u.query, u.fragment]))
176+
else:
177+
result.add(urlunparse([u.scheme, u.netloc, u.path, p, u.query, u.fragment]))
175178

176179

177180
if not scope or 'path' in scope:
@@ -187,10 +190,8 @@ def mixPayload(url, payloads, scope=[], append=False):
187190
if not scope or 'query' in scope:
188191
for k in qs_dict.keys():
189192
tmp_dict = copy.deepcopy(qs_dict)
190-
if append:
191-
tmp_dict[k] = tmp_dict[k] + p
192-
else:
193-
tmp_dict[k] = p
193+
tmp_dict[k] = tmp_dict[k] + p if append else p
194+
194195
tmp_qs = unquote(urlencode(tmp_dict))
195196

196197
result.add(urlunparse([u.scheme, u.netloc, u.path, u.params, tmp_qs, u.fragment]))

0 commit comments

Comments
 (0)