Browse Source

add URL validation for trailing slash (closes #18)

Signed-off-by: r4sas <r4sas@i2pmail.org>
dependabot/add-v2-config-file
R4SAS 5 years ago
parent
commit
7c5ba2fdbe
Signed by untrusted user: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 6
      pbincli/cli.py
  2. 6
      pbincli/utils.py

6
pbincli/cli.py

@ -3,7 +3,7 @@ import os, sys, argparse @@ -3,7 +3,7 @@ import os, sys, argparse
import pbincli.actions
from pbincli.api import PrivateBin
from pbincli.utils import PBinCLIException
from pbincli.utils import PBinCLIException, validate_url
CONFIG_PATHS = [os.path.join(".", "pbincli.conf", ),
os.path.join(os.getenv("HOME") or "~", ".config", "pbincli", "pbincli.conf") ]
@ -78,13 +78,15 @@ def main(): @@ -78,13 +78,15 @@ def main():
var = "PRIVATEBIN_{}".format(key.upper())
if var in os.environ: CONFIG[key] = os.getenv(var)
PBIN_URL = validate_url(CONFIG["server"])
SETTINGS = {
"proxy": CONFIG["proxy"],
"nocheckcert": args.no_check_certificate,
"noinsecurewarn": args.no_insecure_warning
}
api_client = PrivateBin(CONFIG["server"], settings=SETTINGS)
api_client = PrivateBin(PBIN_URL, settings=SETTINGS)
if hasattr(args, "func"):
try:

6
pbincli/utils.py

@ -23,3 +23,9 @@ def check_writable(f): @@ -23,3 +23,9 @@ def check_writable(f):
def json_encode(s):
return json.dumps(s, separators=(',',':')).encode()
def validate_url(s):
if not s.endswith('/'):
s = s + "/"
return s

Loading…
Cancel
Save