Skip to content

Commit

Permalink
Fixed index out of range error
Browse files Browse the repository at this point in the history
There could be a situation where `findall` doesn't find anything, in this case I add a check to avoid errors.
  • Loading branch information
Roi authored Mar 25, 2021
1 parent 44acebc commit 21b4e9b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions webwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
reg = """\]LEDEBUT\]([\s\S]*)\]LAFIN\]"""

req = httpx.get(host.replace("WRAP", "echo -n ]LEDEBUT]$(whoami)[$(hostname)[$(pwd)]LAFIN]"))
prefixes = re.compile(reg).findall(req.text)[0].split("[")
path = prefixes[2]
prefixes = re.compile(reg).findall(req.text)
if not prefixes:
print("Req.text not found!\n")
exit(-1)
path = prefixes[0].split("[")[2]
prefix = colored(prefixes[0] + "@" + prefixes[1], "red") + ":" + colored(prefixes[2], "cyan") + "$ "
print("")

Expand Down

0 comments on commit 21b4e9b

Please sign in to comment.