mirror of
https://github.com/9001/copyparty.git
synced 2025-11-24 07:23:22 -07:00
ENTERPRISE file extensions (#941 omake);
in case a snakeoil salesman managed to convince your workplace into purchasing their "internet security solution" which blocks downloads of certain files according to file extensions -- or, in other words, smoke and mirrors, with a comforting false sense of security
This commit is contained in:
parent
c9e45c12d8
commit
b624a38747
|
|
@ -55,7 +55,7 @@ except:
|
|||
zs = """
|
||||
web/a/partyfuse.py
|
||||
web/a/u2c.py
|
||||
web/a/webdav-cfg.bat
|
||||
web/a/webdav-cfg.txt
|
||||
web/baguettebox.js
|
||||
web/browser.css
|
||||
web/browser.html
|
||||
|
|
@ -125,6 +125,11 @@ web/util.js
|
|||
web/w.hash.js
|
||||
"""
|
||||
RES = set(zs.strip().split("\n"))
|
||||
RESM = {
|
||||
"web/a/partyfuse.txt": "web/a/partyfuse.py",
|
||||
"web/a/u2c.txt": "web/a/u2c.py",
|
||||
"web/a/webdav-cfg.bat": "web/a/webdav-cfg.txt",
|
||||
}
|
||||
|
||||
|
||||
class EnvParams(object):
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
from .__init__ import ANYWIN, RES, TYPE_CHECKING, EnvParams, unicode
|
||||
from .__init__ import ANYWIN, RES, RESM, TYPE_CHECKING, EnvParams, unicode
|
||||
from .__version__ import S_VERSION
|
||||
from .authsrv import LEELOO_DALLAS, VFS # typechk
|
||||
from .bos import bos
|
||||
|
|
@ -1275,6 +1275,20 @@ class HttpCli(object):
|
|||
else:
|
||||
return self.tx_res(res_path)
|
||||
|
||||
if res_path in RESM:
|
||||
ap = self.E.mod_ + RESM[res_path]
|
||||
if (
|
||||
"txt" not in self.uparam
|
||||
and "mime" not in self.uparam
|
||||
and not self.ouparam.get("dl")
|
||||
):
|
||||
# return mimetype matching request extension
|
||||
self.ouparam["dl"] = res_path.split("/")[-1]
|
||||
if bos.path.exists(ap) or bos.path.exists(ap + ".gz"):
|
||||
return self.tx_file(ap)
|
||||
else:
|
||||
return self.tx_res(res_path)
|
||||
|
||||
self.tx_404()
|
||||
return False
|
||||
|
||||
|
|
@ -4179,8 +4193,11 @@ class HttpCli(object):
|
|||
# force download
|
||||
|
||||
if "dl" in self.ouparam:
|
||||
cdis = gen_content_disposition(os.path.basename(req_path))
|
||||
self.out_headers["Content-Disposition"] = cdis
|
||||
cdis = self.ouparam["dl"] or req_path
|
||||
zs = gen_content_disposition(os.path.basename(cdis))
|
||||
self.out_headers["Content-Disposition"] = zs
|
||||
else:
|
||||
cdis = req_path
|
||||
|
||||
#
|
||||
# if-modified
|
||||
|
|
@ -4246,7 +4263,7 @@ class HttpCli(object):
|
|||
elif "mime" in self.uparam:
|
||||
mime = str(self.uparam.get("mime"))
|
||||
else:
|
||||
mime = guess_mime(req_path)
|
||||
mime = guess_mime(cdis)
|
||||
|
||||
logmsg += unicode(status) + logtail
|
||||
|
||||
|
|
@ -4354,8 +4371,11 @@ class HttpCli(object):
|
|||
# force download
|
||||
|
||||
if "dl" in self.ouparam:
|
||||
cdis = gen_content_disposition(os.path.basename(req_path))
|
||||
self.out_headers["Content-Disposition"] = cdis
|
||||
cdis = self.ouparam["dl"] or req_path
|
||||
zs = gen_content_disposition(os.path.basename(cdis))
|
||||
self.out_headers["Content-Disposition"] = zs
|
||||
else:
|
||||
cdis = req_path
|
||||
|
||||
#
|
||||
# if-modified
|
||||
|
|
@ -4483,7 +4503,7 @@ class HttpCli(object):
|
|||
elif "rmagic" in self.vn.flags:
|
||||
mime = guess_mime(req_path, fs_path)
|
||||
else:
|
||||
mime = guess_mime(req_path)
|
||||
mime = guess_mime(cdis)
|
||||
|
||||
if "nohtml" in self.vn.flags and "html" in mime:
|
||||
mime = "text/plain; charset=utf-8"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
# which should help on really slow connections
|
||||
# but then why are you using copyparty in the first place
|
||||
|
||||
pk: $(addsuffix .gz, $(wildcard tl/*.js *.js *.css))
|
||||
un: $(addsuffix .un, $(wildcard tl/*.gz *.gz))
|
||||
pk: $(addsuffix .gz, $(wildcard tl/*.js *.js *.css) \
|
||||
a/partyfuse.py a/u2c.py a/webdav-cfg.txt )
|
||||
un: $(addsuffix .un, $(wildcard tl/*.gz *.gz a/*.gz))
|
||||
|
||||
%.gz: %
|
||||
pigz -11 -J 34 -I 573 $<
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
<li>old version of rclone? replace all <code>=</code> with <code> </code> (space)</li>
|
||||
</ul>
|
||||
|
||||
<p>if you want to use the native WebDAV client in windows instead (slow and buggy), first run <a href="{{ r }}/.cpr/a/webdav-cfg.bat">webdav-cfg.bat</a> to remove the 47 MiB filesize limit (also fixes latency and password login), then connect:</p>
|
||||
<p>if you want to use the native WebDAV client in windows instead (slow and buggy), first run <a href="{{ r }}/.cpr/a/webdav-cfg.txt?dl=webdav-cfg.bat">webdav-cfg.bat</a> to remove the 47 MiB filesize limit (also fixes latency and password login), then connect:</p>
|
||||
<pre>
|
||||
{%- if un %}
|
||||
net use <b>w:</b> http{{ s }}://{{ ep }}/{{ rvp }}{% if accs %} <b>{{ pw }}</b> /user:{{ b_un }}{% endif %}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,8 @@ copyparty = [
|
|||
"web/*.xml",
|
||||
"web/tl/*.js",
|
||||
"web/tl/*.gz",
|
||||
"web/a/*.bat",
|
||||
"web/a/*.txt",
|
||||
"web/a/*.gz",
|
||||
"web/deps/*.gz",
|
||||
"web/deps/*.woff*",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ gzres() {
|
|||
$pk "$f" &
|
||||
done < <(
|
||||
find -printf '%s %p\n' |
|
||||
grep -E '\.(js|css)$' |
|
||||
grep -E '\.(js|css)$|/web/a/[^_].*\.(py|txt)$' |
|
||||
grep -vF /deps/ |
|
||||
sort -nr
|
||||
)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ copyparty/web/a,
|
|||
copyparty/web/a/__init__.py,
|
||||
copyparty/web/a/partyfuse.py,
|
||||
copyparty/web/a/u2c.py,
|
||||
copyparty/web/a/webdav-cfg.bat,
|
||||
copyparty/web/a/webdav-cfg.txt,
|
||||
copyparty/web/baguettebox.js,
|
||||
copyparty/web/browser.css,
|
||||
copyparty/web/browser.html,
|
||||
|
|
|
|||
Loading…
Reference in a new issue