Fix snap chromium path collapsing to /usr/bin/snap
readlink/realpath of /snap/bin/chromium becomes /usr/bin/snap, which is not a browser and breaks DrissionPage launch. Keep the snap wrapper path, reject snap host basenames, and prefer real deb chromium binaries.
This commit is contained in:
1 parent
a790a371a8
commit
767516745e
5 files changed
+289
-70
No files matched your search
@@ -232,20 +232,34 @@ def create_standalone_page(
|
||||
log(f"headed browser DISPLAY={display!r}")
|
||||
|
||||
# Prefer Chromium: Google Chrome blocks --load-extension (turnstilePatch).
|
||||
# Never use realpath(/snap/bin/chromium)=/usr/bin/snap — that is not a browser.
|
||||
for cand in (
|
||||
"/usr/bin/chromium",
|
||||
"/usr/bin/chromium-browser",
|
||||
"/usr/lib/chromium/chromium",
|
||||
"/snap/bin/chromium",
|
||||
"/usr/bin/google-chrome-stable",
|
||||
"/usr/bin/google-chrome",
|
||||
):
|
||||
if os.path.isfile(cand) or os.path.islink(cand):
|
||||
if not (os.path.isfile(cand) or os.path.islink(cand)):
|
||||
continue
|
||||
if os.path.basename(cand) in ("snap", "snap-confine", "snapd"):
|
||||
continue
|
||||
use = cand
|
||||
if not cand.startswith("/snap/bin/"):
|
||||
try:
|
||||
opts.set_browser_path(cand)
|
||||
log(f"browser path={cand}")
|
||||
real = os.path.realpath(cand)
|
||||
if os.path.basename(real) not in ("snap", "snap-confine", "snapd"):
|
||||
if "chromium" in real.lower() or "chrome" in real.lower():
|
||||
use = real
|
||||
except Exception:
|
||||
pass
|
||||
break
|
||||
try:
|
||||
opts.set_browser_path(use)
|
||||
log(f"browser path={use}")
|
||||
except Exception:
|
||||
pass
|
||||
break
|
||||
|
||||
from .proxyutil import proxy_for_chromium, proxy_log_label, resolve_proxy
|
||||
|
||||
|
||||
Reference in new issue
Block a user