mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Fix incorrect handing of default node parameters in SSD subscription. Fix unable to parse some Clash rule-providers (#289). Fix not filtering inline comments in some Surge rulesets. (#285) Add Cron task options. Add clean context option for persisting a JS context across the whole request. Replace JS engine with QuickJS.
94 lines
2.8 KiB
Diff
94 lines
2.8 KiB
Diff
--- quickjs-libc.c 2021-03-23 15:04:09.604314700 +0800
|
|
+++ patched.c 2021-03-23 15:04:35.109289500 +0800
|
|
@@ -132,6 +132,29 @@
|
|
static uint64_t os_pending_signals;
|
|
static int (*os_poll_func)(JSContext *ctx);
|
|
|
|
+static char *_realpath(const char *path, char *resolved_path)
|
|
+{
|
|
+#if defined(_WIN32)
|
|
+ BOOL allocated = FALSE;
|
|
+ if(resolved_path == NULL)
|
|
+ {
|
|
+ resolved_path = (char*) malloc(PATH_MAX);
|
|
+ allocated = TRUE;
|
|
+ }
|
|
+ DWORD len = GetFullPathNameA(path, PATH_MAX, resolved_path, NULL);
|
|
+ if(!len || len >= PATH_MAX)
|
|
+ {
|
|
+ if(allocated)
|
|
+ free(resolved_path);
|
|
+ return NULL;
|
|
+ }
|
|
+ resolved_path[len] = '\0';
|
|
+ return resolved_path;
|
|
+#else
|
|
+ return realpath(path, resolved_path);
|
|
+#endif // _WIN32
|
|
+}
|
|
+
|
|
static void js_std_dbuf_init(JSContext *ctx, DynBuf *s)
|
|
{
|
|
dbuf_init2(s, JS_GetRuntime(ctx), (DynBufReallocFunc *)js_realloc_rt);
|
|
@@ -530,19 +553,19 @@
|
|
return -1;
|
|
if (!strchr(module_name, ':')) {
|
|
strcpy(buf, "file://");
|
|
-#if !defined(_WIN32)
|
|
+//#if !defined(_WIN32)
|
|
/* realpath() cannot be used with modules compiled with qjsc
|
|
because the corresponding module source code is not
|
|
necessarily present */
|
|
if (use_realpath) {
|
|
- char *res = realpath(module_name, buf + strlen(buf));
|
|
+ char *res = _realpath(module_name, buf + strlen(buf));
|
|
if (!res) {
|
|
JS_ThrowTypeError(ctx, "realpath failure");
|
|
JS_FreeCString(ctx, module_name);
|
|
return -1;
|
|
}
|
|
} else
|
|
-#endif
|
|
+//#endif
|
|
{
|
|
pstrcat(buf, sizeof(buf), module_name);
|
|
}
|
|
@@ -2588,8 +2611,6 @@
|
|
return JS_NewInt32(ctx, ret);
|
|
}
|
|
|
|
-#if !defined(_WIN32)
|
|
-
|
|
/* return [path, errorcode] */
|
|
static JSValue js_os_realpath(JSContext *ctx, JSValueConst this_val,
|
|
int argc, JSValueConst *argv)
|
|
@@ -2601,7 +2622,7 @@
|
|
path = JS_ToCString(ctx, argv[0]);
|
|
if (!path)
|
|
return JS_EXCEPTION;
|
|
- res = realpath(path, buf);
|
|
+ res = _realpath(path, buf);
|
|
JS_FreeCString(ctx, path);
|
|
if (!res) {
|
|
buf[0] = '\0';
|
|
@@ -2612,6 +2633,8 @@
|
|
return make_string_error(ctx, buf, err);
|
|
}
|
|
|
|
+#if !defined(_WIN32)
|
|
+
|
|
static JSValue js_os_symlink(JSContext *ctx, JSValueConst this_val,
|
|
int argc, JSValueConst *argv)
|
|
{
|
|
@@ -3598,9 +3621,9 @@
|
|
#endif
|
|
JS_CFUNC_MAGIC_DEF("stat", 1, js_os_stat, 0 ),
|
|
JS_CFUNC_DEF("utimes", 3, js_os_utimes ),
|
|
+ JS_CFUNC_DEF("realpath", 1, js_os_realpath ),
|
|
#if !defined(_WIN32)
|
|
JS_CFUNC_MAGIC_DEF("lstat", 1, js_os_stat, 1 ),
|
|
- JS_CFUNC_DEF("realpath", 1, js_os_realpath ),
|
|
JS_CFUNC_DEF("symlink", 2, js_os_symlink ),
|
|
JS_CFUNC_DEF("readlink", 1, js_os_readlink ),
|
|
JS_CFUNC_DEF("exec", 1, js_os_exec ),
|