mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-28 15:27:11 -05:00
Check the file is a valid file or dir (not just that it exists)
This commit is contained in:
parent
5c390f1bd9
commit
9154faf351
@ -68,12 +68,15 @@ def main(cwd=None):
|
|||||||
# Validation
|
# Validation
|
||||||
valid = True
|
valid = True
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
if not os.path.exists(filename):
|
if not os.path.isfile(filename) and not os.path.isdir(filename):
|
||||||
print(strings._("not_a_file").format(filename))
|
print(strings._("not_a_file").format(filename))
|
||||||
valid = False
|
valid = False
|
||||||
if not os.access(filename, os.R_OK):
|
if not os.access(filename, os.R_OK):
|
||||||
print(strings._("not_a_readable_file").format(filename))
|
print(strings._("not_a_readable_file").format(filename))
|
||||||
valid = False
|
valid = False
|
||||||
|
if os.path.isdir(filename) and os.path.getsize(filename) < 4096:
|
||||||
|
print(strings._("not_a_file").format(filename))
|
||||||
|
valid = False
|
||||||
if not valid:
|
if not valid:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
@ -91,12 +91,15 @@ def main():
|
|||||||
if filenames:
|
if filenames:
|
||||||
valid = True
|
valid = True
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
if not os.path.exists(filename):
|
if not os.path.isfile(filename) and not os.path.isdir(filename):
|
||||||
Alert(strings._("not_a_file", True).format(filename))
|
Alert(strings._("not_a_file", True).format(filename))
|
||||||
valid = False
|
valid = False
|
||||||
if not os.access(filename, os.R_OK):
|
if not os.access(filename, os.R_OK):
|
||||||
Alert(strings._("not_a_readable_file", True).format(filename))
|
Alert(strings._("not_a_readable_file", True).format(filename))
|
||||||
valid = False
|
valid = False
|
||||||
|
if os.path.isdir(filename) and os.path.getsize(filename) < 4096:
|
||||||
|
Alert(strings._("not_a_file", True).format(filename))
|
||||||
|
valid = False
|
||||||
if not valid:
|
if not valid:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"give_this_url": "Give this URL to the person you're sending the file to:",
|
"give_this_url": "Give this URL to the person you're sending the file to:",
|
||||||
"give_this_url_stealth": "Give this URL and HidServAuth line to the person you're sending the file to:",
|
"give_this_url_stealth": "Give this URL and HidServAuth line to the person you're sending the file to:",
|
||||||
"ctrlc_to_stop": "Press Ctrl-C to stop server",
|
"ctrlc_to_stop": "Press Ctrl-C to stop server",
|
||||||
"not_a_file": "{0:s} is not a file.",
|
"not_a_file": "{0:s} is not a valid file.",
|
||||||
"not_a_readable_file": "{0:s} is not a readable file.",
|
"not_a_readable_file": "{0:s} is not a readable file.",
|
||||||
"no_available_port": "Could not start the Onion service as there was no available port.",
|
"no_available_port": "Could not start the Onion service as there was no available port.",
|
||||||
"download_page_loaded": "Download page loaded",
|
"download_page_loaded": "Download page loaded",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user