mirror of
https://github.com/9001/copyparty.git
synced 2025-10-23 04:52:21 +00: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:
@@ -55,7 +55,7 @@ except:
|
|||||||
zs = """
|
zs = """
|
||||||
web/a/partyfuse.py
|
web/a/partyfuse.py
|
||||||
web/a/u2c.py
|
web/a/u2c.py
|
||||||
web/a/webdav-cfg.bat
|
web/a/webdav-cfg.txt
|
||||||
web/baguettebox.js
|
web/baguettebox.js
|
||||||
web/browser.css
|
web/browser.css
|
||||||
web/browser.html
|
web/browser.html
|
||||||
@@ -125,6 +125,11 @@ web/util.js
|
|||||||
web/w.hash.js
|
web/w.hash.js
|
||||||
"""
|
"""
|
||||||
RES = set(zs.strip().split("\n"))
|
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):
|
class EnvParams(object):
|
||||||
|
@@ -30,7 +30,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
pass
|
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 .__version__ import S_VERSION
|
||||||
from .authsrv import LEELOO_DALLAS, VFS # typechk
|
from .authsrv import LEELOO_DALLAS, VFS # typechk
|
||||||
from .bos import bos
|
from .bos import bos
|
||||||
@@ -1275,6 +1275,20 @@ class HttpCli(object):
|
|||||||
else:
|
else:
|
||||||
return self.tx_res(res_path)
|
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()
|
self.tx_404()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -4179,8 +4193,11 @@ class HttpCli(object):
|
|||||||
# force download
|
# force download
|
||||||
|
|
||||||
if "dl" in self.ouparam:
|
if "dl" in self.ouparam:
|
||||||
cdis = gen_content_disposition(os.path.basename(req_path))
|
cdis = self.ouparam["dl"] or req_path
|
||||||
self.out_headers["Content-Disposition"] = cdis
|
zs = gen_content_disposition(os.path.basename(cdis))
|
||||||
|
self.out_headers["Content-Disposition"] = zs
|
||||||
|
else:
|
||||||
|
cdis = req_path
|
||||||
|
|
||||||
#
|
#
|
||||||
# if-modified
|
# if-modified
|
||||||
@@ -4246,7 +4263,7 @@ class HttpCli(object):
|
|||||||
elif "mime" in self.uparam:
|
elif "mime" in self.uparam:
|
||||||
mime = str(self.uparam.get("mime"))
|
mime = str(self.uparam.get("mime"))
|
||||||
else:
|
else:
|
||||||
mime = guess_mime(req_path)
|
mime = guess_mime(cdis)
|
||||||
|
|
||||||
logmsg += unicode(status) + logtail
|
logmsg += unicode(status) + logtail
|
||||||
|
|
||||||
@@ -4354,8 +4371,11 @@ class HttpCli(object):
|
|||||||
# force download
|
# force download
|
||||||
|
|
||||||
if "dl" in self.ouparam:
|
if "dl" in self.ouparam:
|
||||||
cdis = gen_content_disposition(os.path.basename(req_path))
|
cdis = self.ouparam["dl"] or req_path
|
||||||
self.out_headers["Content-Disposition"] = cdis
|
zs = gen_content_disposition(os.path.basename(cdis))
|
||||||
|
self.out_headers["Content-Disposition"] = zs
|
||||||
|
else:
|
||||||
|
cdis = req_path
|
||||||
|
|
||||||
#
|
#
|
||||||
# if-modified
|
# if-modified
|
||||||
@@ -4483,7 +4503,7 @@ class HttpCli(object):
|
|||||||
elif "rmagic" in self.vn.flags:
|
elif "rmagic" in self.vn.flags:
|
||||||
mime = guess_mime(req_path, fs_path)
|
mime = guess_mime(req_path, fs_path)
|
||||||
else:
|
else:
|
||||||
mime = guess_mime(req_path)
|
mime = guess_mime(cdis)
|
||||||
|
|
||||||
if "nohtml" in self.vn.flags and "html" in mime:
|
if "nohtml" in self.vn.flags and "html" in mime:
|
||||||
mime = "text/plain; charset=utf-8"
|
mime = "text/plain; charset=utf-8"
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
# which should help on really slow connections
|
# which should help on really slow connections
|
||||||
# but then why are you using copyparty in the first place
|
# but then why are you using copyparty in the first place
|
||||||
|
|
||||||
pk: $(addsuffix .gz, $(wildcard tl/*.js *.js *.css))
|
pk: $(addsuffix .gz, $(wildcard tl/*.js *.js *.css) \
|
||||||
un: $(addsuffix .un, $(wildcard tl/*.gz *.gz))
|
a/partyfuse.py a/u2c.py a/webdav-cfg.txt )
|
||||||
|
un: $(addsuffix .un, $(wildcard tl/*.gz *.gz a/*.gz))
|
||||||
|
|
||||||
%.gz: %
|
%.gz: %
|
||||||
pigz -11 -J 34 -I 573 $<
|
pigz -11 -J 34 -I 573 $<
|
||||||
|
@@ -64,7 +64,7 @@
|
|||||||
<li>old version of rclone? replace all <code>=</code> with <code> </code> (space)</li>
|
<li>old version of rclone? replace all <code>=</code> with <code> </code> (space)</li>
|
||||||
</ul>
|
</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>
|
<pre>
|
||||||
{%- if un %}
|
{%- if un %}
|
||||||
net use <b>w:</b> http{{ s }}://{{ ep }}/{{ rvp }}{% if accs %} <b>{{ pw }}</b> /user:{{ b_un }}{% endif %}
|
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/*.xml",
|
||||||
"web/tl/*.js",
|
"web/tl/*.js",
|
||||||
"web/tl/*.gz",
|
"web/tl/*.gz",
|
||||||
"web/a/*.bat",
|
"web/a/*.txt",
|
||||||
|
"web/a/*.gz",
|
||||||
"web/deps/*.gz",
|
"web/deps/*.gz",
|
||||||
"web/deps/*.woff*",
|
"web/deps/*.woff*",
|
||||||
]
|
]
|
||||||
|
@@ -571,7 +571,7 @@ gzres() {
|
|||||||
$pk "$f" &
|
$pk "$f" &
|
||||||
done < <(
|
done < <(
|
||||||
find -printf '%s %p\n' |
|
find -printf '%s %p\n' |
|
||||||
grep -E '\.(js|css)$' |
|
grep -E '\.(js|css)$|/web/a/[^_].*\.(py|txt)$' |
|
||||||
grep -vF /deps/ |
|
grep -vF /deps/ |
|
||||||
sort -nr
|
sort -nr
|
||||||
)
|
)
|
||||||
|
@@ -66,7 +66,7 @@ copyparty/web/a,
|
|||||||
copyparty/web/a/__init__.py,
|
copyparty/web/a/__init__.py,
|
||||||
copyparty/web/a/partyfuse.py,
|
copyparty/web/a/partyfuse.py,
|
||||||
copyparty/web/a/u2c.py,
|
copyparty/web/a/u2c.py,
|
||||||
copyparty/web/a/webdav-cfg.bat,
|
copyparty/web/a/webdav-cfg.txt,
|
||||||
copyparty/web/baguettebox.js,
|
copyparty/web/baguettebox.js,
|
||||||
copyparty/web/browser.css,
|
copyparty/web/browser.css,
|
||||||
copyparty/web/browser.html,
|
copyparty/web/browser.html,
|
||||||
|
Reference in New Issue
Block a user