mirror of
https://github.com/MrLowPr/overdrive.git
synced 2026-10-18 09:01:06 +02:00
feat: browser capture for LinkVault, Akirabox and Datanodes
This commit is contained in:
1 parent
7454d7be1c
commit
6cd4add902
14 files changed
+386
-34
No files matched your search
@@ -19,12 +19,16 @@ bool text(JSContext* ctx, JSValueConst value, std::string& out) {
|
||||
JSValue capture(JSContext* ctx, JSValueConst, int argc, JSValueConst* argv) {
|
||||
std::string prefix, suffix;
|
||||
double timeout = 0;
|
||||
if (argc < 3 || !text(ctx, argv[0], prefix) || prefix != "https://vikingfile.com/d/" ||
|
||||
if (argc < 3 || !text(ctx, argv[0], prefix) ||
|
||||
(prefix != "https://vikingfile.com/d/" && prefix != "https://") ||
|
||||
!text(ctx, argv[1], suffix) || suffix.empty() || suffix[0] != '/' ||
|
||||
suffix.find('/', 1) != std::string::npos || suffix.find('\\') != std::string::npos ||
|
||||
suffix.find("..") != std::string::npos || JS_ToFloat64(ctx, &timeout, argv[2]) ||
|
||||
suffix.find("..") != std::string::npos ||
|
||||
/* The whole scheme means anchor mode, which needs a real anchor. */
|
||||
(prefix == "https://" && suffix.size() < 5) ||
|
||||
JS_ToFloat64(ctx, &timeout, argv[2]) ||
|
||||
!std::isfinite(timeout) || timeout < 1 || timeout > 180 || std::floor(timeout) != timeout)
|
||||
return JS_ThrowTypeError(ctx, "browser.capture: expected the Vikingfile prefix, /filename (160 UTF-8 bytes), and 1..180 seconds");
|
||||
return JS_ThrowTypeError(ctx, "browser.capture: expected the Vikingfile prefix, or https:// with an anchor of 4..160 bytes, then /filename (160 UTF-8 bytes) and 1..180 seconds");
|
||||
for (const unsigned char c : suffix) if (c < 32 || c == 127)
|
||||
return JS_ThrowTypeError(ctx, "browser.capture: filename contains a control character");
|
||||
std::string error;
|
||||
|
||||
Reference in new issue
Block a user