]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
1. Add check for invalid characters in menu_class plugin.
authorlongpanda <admin@ventoy.net>
Fri, 3 Dec 2021 10:31:09 +0000 (18:31 +0800)
committerlongpanda <admin@ventoy.net>
Fri, 3 Dec 2021 10:31:09 +0000 (18:31 +0800)
2. Optimization for help language list process

12 files changed:
.github/ISSUE_TEMPLATE/issue_template.yml
Plugson/build.sh
Plugson/pack.sh
Plugson/src/Web/ventoy_http.c
Plugson/src/Web/ventoy_http.h
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
Plugson/www/buildtime
Plugson/www/helplist [new file with mode: 0644]
Plugson/www/index.html
Plugson/www/plugson_menu_class.html
Plugson/www/static/js/jquery.validate.vtoymethods.js
Plugson/www/static/js/vtoy.js

index 3003f3646764f1e9a4c81b0d6056c3b500eb59e7..d0e78bb331adebe2e938c0870e63552db7dd2963 100644 (file)
@@ -21,7 +21,7 @@ body:
     attributes:
       label: Ventoy Version
       description: What version of ventoy are you running?
-      placeholder: 1.0.61
+      placeholder: 1.0.62
     validations:
       required: true
   - type: dropdown
index d53b48c6d139bc28e5677d0b02bfe7754d6f8d5e..095d07094615c7bcbcb391aceee5633546ef7b12 100644 (file)
@@ -76,4 +76,3 @@ build_func "gcc -m32" '32' 'i386'
 build_func "aarch64-linux-gnu-gcc" 'aa64' 'aarch64'
 build_func "mips-linux-gnu-gcc -mips64r2 -mabi=64" 'm64e' 'mips64el'
 
-
index 6eed00edd4496e25036047919bb8a87306ced6ab..46fbf0324b3b100ca840fb76008096af4781eb1a 100644 (file)
@@ -17,6 +17,10 @@ if [ -f ./www.tar.xz ]; then
     rm -f ./www.tar.xz
 fi
 
+[ -f ./www/helplist ] && rm -f ./www/helplist
+ls -1 ../INSTALL/grub/help/ | while read line; do 
+    echo -n ${line:0:5} >> ./www/helplist
+done 
 echo -n "$plugson_verion" > ./www/buildtime
 
 tar cf www.tar www
index 7ecce2215a325e0b37364cfa34cacb4f78b53dde..7f17a4b5bfccb7d7ea7d617d6eff304505164344 100644 (file)
@@ -60,12 +60,7 @@ static const char *g_ventoy_kbd_layout[] =
     NULL
 };
 
-static const char *g_ventoy_help_lang[] =
-{
-    "de_DE", "en_US", "fr_FR", "hr_HR", "id_ID", "pt_PT", "sr_CY", "sr_SR", "tr_TR", "zh_CN", 
-        
-    NULL
-};
+static char g_ventoy_help_lang[MAX_LANGUAGE][8];
 
 static char g_pub_path[2 * MAX_PATH];
 static data_control g_data_control[bios_max + 1];
@@ -622,7 +617,7 @@ int ventoy_data_json_control(data_control *ctrl, char *buf, int buflen)
     VTOY_JSON_FMT_KEY("help_list");
     VTOY_JSON_FMT_ARY_BEGIN();
 
-    for (i = 0; g_ventoy_help_lang[i]; i++)
+    for (i = 0; g_ventoy_help_lang[i][0]; i++)
     {
         VTOY_JSON_FMT_ITEM(g_ventoy_help_lang[i]);        
     }
@@ -3839,7 +3834,7 @@ static int ventoy_parse_control(VTOY_JSON *json, void *p)
             }
             else if (strcmp(child->pcName, "VTOY_HELP_TXT_LANGUAGE") == 0)
             {
-                for (i = 0; g_ventoy_help_lang[i]; i++)
+                for (i = 0; g_ventoy_help_lang[i][0]; i++)
                 {
                     if (strcmp(child->unData.pcStrVal, g_ventoy_help_lang[i]) == 0)
                     {
@@ -5051,11 +5046,41 @@ int ventoy_http_stop(void)
 
 int ventoy_http_init(void)
 {
+    int i = 0;
+    
+#ifdef VENTOY_SIM
+    char *Buffer = NULL;
+    int BufLen = 0;
+
+    ventoy_read_file_to_buf("www/helplist", 4, (void **)&Buffer, &BufLen);
+    if (Buffer)
+    {
+        for (i = 0; i < BufLen / 5; i++)
+        {
+            memcpy(g_ventoy_help_lang[i], Buffer + i * 5, 5);
+            g_ventoy_help_lang[i][5] = 0;
+        }
+        free(Buffer);
+    }
+#else
+    ventoy_file *file;
+    file = ventoy_tar_find_file("www/helplist");
+    if (file)
+    {
+        for (i = 0; i < file->size / 5; i++)
+        {
+            memcpy(g_ventoy_help_lang[i], (char *)(file->addr) + i * 5, 5);
+            g_ventoy_help_lang[i][5] = 0;
+        }
+    }
+#endif
+
     if (!g_pub_json_buffer)
     {
         g_pub_json_buffer = malloc(JSON_BUF_MAX * 2);
         g_pub_save_buffer = g_pub_json_buffer + JSON_BUF_MAX;
-    }
+    }   
+
 
     pthread_mutex_init(&g_api_mutex, NULL);
     return 0;
index 904fe05e750cc2359bba83d55f4996bb7b981c34..d5607df1c17795cf929fa694a04f91148fea2104 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <civetweb.h>
 
+#define MAX_LANGUAGE  128
 
 #define L1 "    "
 #define L2 "        "
index d33e7be91302dad9c42997d5826758b506e89ea0..79fbbbefa29ebcef28eaa4335b52ab85c3e9af7d 100644 (file)
Binary files a/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe and b/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe differ
index 38f77a72386e292d6ebc6c07a6d4e8afe5c612ba..483a8bfcdc67600bc1efdae6172efed8784e1402 100644 (file)
@@ -1 +1 @@
-20211201 20:08:18
\ No newline at end of file
+20211203 17:44:10
\ No newline at end of file
diff --git a/Plugson/www/helplist b/Plugson/www/helplist
new file mode 100644 (file)
index 0000000..3cd79e6
--- /dev/null
@@ -0,0 +1 @@
+de_DEen_USfr_FRhr_HRid_IDja_JPpt_PTsr_CYsr_SRtr_TRzh_CN
\ No newline at end of file
index 66cc32ce2058b2cfda3165b782e057c4aa9ee916..ed601cdaf2bd7305dae88b023e37449828dc700d 100644 (file)
 \r
         <footer class="main-footer">\r
             <div class="pull-right hidden-xs">\r
-                <b id="plugson_build_date">20211201 20:08:18</b>
+                <b id="plugson_build_date">20211203 17:44:10</b>
             </div>\r
             <strong><a href="https://www.ventoy.net" target="_blank">https://www.ventoy.net</a></strong>\r
         </footer>\r
index 940bd6db458a57332f9ff7a61ea5a24086ef4419..c451662c098d3c1bdcfd8d5eaccb4eb4f01af3af 100644 (file)
       }\r
     }\r
 \r
-    if (extra.indexOf("\"") >= 0) {\r
-      Message.error(g_current_language === 'en' ? "Class can not contains double quotes." : "Class 不能包含双引号。");\r
-      return;\r
-    }\r
-\r
     callVtoy({\r
       method : 'class_add',\r
       index: current_tab_index,\r
   }\r
 \r
   function OnAddKeyClass(key, value) {\r
+    if (!ventoy_check_file_name_char(key)) {\r
+      Message.error(g_current_language === 'en' ? "As part of file name, key can not include invalid characters!" : "作为文件名的一部分,key 中不能包含特殊的符号!");\r
+      return;\r
+    }\r
+\r
     AddClassEntry(key, 0, 1, value);\r
   }\r
 \r
index 624c40e59d01ad416c665fa571a42eb74f5d085e..9e640b9b681585cb8387cacd26788938245d308f 100644 (file)
@@ -1,3 +1,16 @@
+function ventoy_check_file_name_char(path) {\r
+    for (var i = 0; i < path.length; i++) {\r
+        var cc = path[i];\r
+        if (cc === '/' || cc === '\\' || cc === '*' || cc === '?' || cc === '"' || cc === '<' || cc === '>' || cc === '|')\r
+        {\r
+            return false;\r
+        }\r
+    }\r
+\r
+    return true;\r
+}\r
+\r
+\r
 (function(factory) {\r
     if (typeof define === "function" && define.amd) {\r
         define(["jquery", "../jquery.validate"], factory);\r
 \r
         return true;\r
     }, 'Can not contain double quotes');\r
+\r
+    $.validator.addMethod('filenamepart', function(value, element, params) {\r
+        if (this.optional(element)) {\r
+            return true;\r
+        }\r
+\r
+        return ventoy_check_file_name_char(value);\r
+    }, 'Invalid characters');\r
     \r
 \r
     $.validator.addMethod('printascii', function(value, element, params) {\r
index aee33796727cb77be02eb1045d7a994857a0b55e..419dbbf1cf73579f3ee5ddd9a89a8b01f17febe6 100644 (file)
@@ -896,6 +896,7 @@ function VtoyCommonChangeLanguage(newlang) {
             utfmaxlen: $.validator.format("The string exceeds the maximum supported length"),\r
             start_slash: $.validator.format("Must start with /"),\r
             noquotes: $.validator.format("Can not include double quotes"),\r
+            filenamepart:$.validator.format("As part of file name, can not include invalid characters"),\r
             printascii: $.validator.format("Can not include non-ascii characters.")\r
         });\r
 \r
@@ -941,6 +942,7 @@ function VtoyCommonChangeLanguage(newlang) {
             utfmaxlen: $.validator.format("超过最大长度"),\r
             start_slash: $.validator.format("必须以反斜杠 / 开头"),\r
             noquotes: $.validator.format("不能包含双引号"),\r
+            filenamepart:$.validator.format("作为文件名的一部分,不能包含特殊的符号"),\r
             printascii: $.validator.format("不能包含中文或其他非 ascii 字符。")\r
         });\r
         \r
@@ -1102,7 +1104,8 @@ var g_set_key_validator = $("#SetKeyForm").validate({
         },\r
         SetKeyValue : {\r
             required: true,\r
-            utfmaxlen: true          \r
+            utfmaxlen: true,\r
+            filenamepart: true        \r
         }\r
     },\r
 \r