@vacantthinker/firefox-addon-framework-easy 2026.530.1431 → 2026.530.1436

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,7 +25,8 @@ export class BaseORM { }
25
25
 
26
26
  ### 📄 File: `src/browserDownload.js`
27
27
  ```javascript
28
- export async function browserDownloadByDownlink({ }
28
+ export async function browserDownloadByDownlink(
29
+ { }
29
30
 
30
31
  ```
31
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vacantthinker/firefox-addon-framework-easy",
3
- "version": "2026.0530.1431",
3
+ "version": "2026.0530.1436",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -5,7 +5,12 @@
5
5
  * @param param0.filename{string}
6
6
  * @returns {Promise<void>}
7
7
  */
8
- export async function browserDownloadByDownlink({ downlink, filename }) {
8
+ export async function browserDownloadByDownlink(
9
+ {
10
+ downlink,
11
+ filename,
12
+ }) {
13
+
9
14
  let url = downlink;
10
15
  await browser.downloads.download({url, filename});
11
16
  }
@@ -65,28 +65,31 @@ export async function serviceGenerateMkvToolNixScript({vid, title}) {
65
65
  }
66
66
 
67
67
  /**
68
- * Ultimate sanitization function: Filters all Chinese/English punctuation, full-width symbols, and illegal characters.
69
- * (100% prevents download errors and copy-paste character corruption)
70
- * @param {string} value - The original video title
71
- * @returns {string} - A clean, safe plaintext/alphanumeric filename
68
+ * 终极清理函数:过滤所有中英文标点、全角符号、以及非法/不可见字符。
69
+ * 100% 预防下载报错和复制粘贴导致的乱码)
70
+ * @param {string} value - 原始视频标题
71
+ * @returns {string} - 干净、安全的纯文本/字母数字文件名
72
72
  */
73
73
  export function serviceRemoveIllegalWord(value) {
74
74
  if (!value) return '';
75
75
 
76
- // 1. Get the first line and trim whitespace from both ends
76
+ // 1. 获取第一行并去除两端空格
77
77
  let name = value.trim().split(/\r?\n/).shift();
78
78
 
79
- // 2. Use Unicode properties to remove all punctuation (\p{P}) and all symbols/geometry (\p{S})
80
- // This natively crushes Chinese full-width punctuation, em dashes (—), Emojis, math symbols, and special brackets.
81
- // Note: The 'u' flag is mandatory to enable Unicode mode in the regex.
79
+ // 2. 使用 Unicode 属性移除所有危险字符:
80
+ // \p{P} = 所有标点符号
81
+ // \p{S} = 所有符号(Emoji、数学符号、货币符号)
82
+ // \p{C} = 所有控制/格式化/代理字符(完美修复不可见的 U+202A/U+202C 导致崩溃的 Bug!)
82
83
  name = name.replace(/[\p{P}\p{S}\p{C}]/gu, ' ');
83
84
 
84
- // 3. Additional defense: Filter out hidden control characters that Firefox/OS are extremely sensitive to (0-31 and 127-159)
85
- name = name.replace(/[\x00-\x1F\x7F-\x9F]/g, ' ');
85
+ // 3. Firefox WebExtension 严格拦截的特殊字符。
86
+ // (大部分已经被 \p{P} 和 \p{S} 处理,但显式移除可以确保彻底杜绝边缘报错)
87
+ name = name.replace(/[~"#%&*:<>?/\\{|}]/g, ' ');
86
88
 
87
- // 4. Clean up Emojis and any remaining surrogate pairs
88
- name = name.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, ' ');
89
+ // 4. 将连续的空格(包括全角/Unicode空格)合并为一个标准空格
90
+ name = name.replace(/[\s\u3000]+/g, ' ').trim();
89
91
 
90
- // 5. Merge consecutive spaces (including Chinese full-width spaces) into a single standard space
91
- return name.replace(/[\s\u3000]+/g, ' ').trim();
92
+ // 5. Firefox 下载 API 会因为文件名以点(.)或连字符(-)开头/结尾而报错
93
+ // 再次修剪以确保绝对安全
94
+ return name.replace(/^[-.]+|[-.]+$/g, '');
92
95
  }