@wahaha216/koishi-plugin-jmcomic 0.2.2 → 0.2.3

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.
Files changed (3) hide show
  1. package/lib/index.js +19 -13
  2. package/package.json +1 -1
  3. package/readme.md +8 -0
package/lib/index.js CHANGED
@@ -135,10 +135,14 @@ function fileSizeAsync(path) {
135
135
  }
136
136
  __name(fileSizeAsync, "fileSizeAsync");
137
137
  function sanitizeFileName(fileName) {
138
- const forbiddenChars = /[<>:"/\\|?*]/g;
139
- fileName = fileName.replace(forbiddenChars, "_");
140
- fileName = fileName.replace(/\s+/g, "_");
141
- fileName = fileName.replace(/[. ]+$/, "");
138
+ const forbiddenAndShellSpecialChars = /[<>:"/\\|?*()[\]{}!#$&;'`~]/g;
139
+ let sanitizedFileName = fileName.replace(forbiddenAndShellSpecialChars, "_");
140
+ sanitizedFileName = sanitizedFileName.replace(/\s+/g, "_");
141
+ sanitizedFileName = sanitizedFileName.replace(/_+/g, "_");
142
+ sanitizedFileName = sanitizedFileName.replace(/^[._]+|[._]+$/g, "");
143
+ if (sanitizedFileName.trim() === "") {
144
+ return "untitled_document";
145
+ }
142
146
  return fileName;
143
147
  }
144
148
  __name(sanitizeFileName, "sanitizeFileName");
@@ -1041,34 +1045,36 @@ var JMAppClient = class _JMAppClient extends JMClientAbstract {
1041
1045
  const id = album.getId();
1042
1046
  const series = album.getSeries();
1043
1047
  const zipName = sanitizeFileName(album.getName());
1044
- const path = `${this.root}/album/${id}`;
1048
+ const path = (0, import_path2.join)(this.root, "album", `${id}`);
1045
1049
  const directorys = [];
1046
1050
  if (series.length > 1) {
1047
1051
  for (const s of series) {
1048
1052
  directorys.push({
1049
- directory: `${path}/decoded/${s.id}`,
1053
+ directory: (0, import_path2.join)(path, "decoded", s.id),
1050
1054
  destpath: `第${s.sort}章`
1051
1055
  });
1052
1056
  }
1053
1057
  } else {
1054
- directorys.push({ directory: `${path}/decoded`, destpath: false });
1058
+ directorys.push({ directory: (0, import_path2.join)(path, "decoded"), destpath: false });
1055
1059
  }
1056
- await archiverImage(directorys, `${path}/${zipName}.zip`, password, level);
1060
+ const zipPath = (0, import_path2.join)(path, `${zipName}.zip`);
1061
+ await archiverImage(directorys, zipPath, password, level);
1057
1062
  if (this.config.debug) this.logger.info(`ZIP ${zipName}.zip 生成完成`);
1058
- return `${path}/${zipName}.zip`;
1063
+ return zipPath;
1059
1064
  }
1060
1065
  async photoToZip(photo, zipName, password, level = 6) {
1061
1066
  const id = photo.getId();
1062
1067
  zipName = sanitizeFileName(zipName);
1063
- const path = `${this.root}/photo/${id}`;
1068
+ const path = (0, import_path2.join)(this.root, "photo", `${id}`);
1069
+ const zipPath = (0, import_path2.join)(path, `${zipName}.zip`);
1064
1070
  await archiverImage(
1065
- [{ directory: `${path}/decoded`, destpath: false }],
1066
- `${path}/${zipName}.zip`,
1071
+ [{ directory: (0, import_path2.join)(path, "decoded"), destpath: false }],
1072
+ zipPath,
1067
1073
  password,
1068
1074
  level
1069
1075
  );
1070
1076
  if (this.config.debug) this.logger.info(`ZIP ${zipName}.zip 生成完成`);
1071
- return `${path}/${zipName}.zip`;
1077
+ return zipPath;
1072
1078
  }
1073
1079
  /**
1074
1080
  * 获取时间戳
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wahaha216/koishi-plugin-jmcomic",
3
3
  "description": "下载JM本子,无需python。支持pdf、zip加密。",
4
- "version": "0.2.2",
4
+ "version": "0.2.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -17,6 +17,14 @@ jm queue
17
17
 
18
18
  ## 更新日志
19
19
 
20
+ <details>
21
+ <summary>0.2.3</summary>
22
+
23
+ 1. 将手动路径拼接替换为join
24
+ 2. 健壮文件名序列化,尝试修复部分文件名导致无法创建文件
25
+
26
+ </details>
27
+
20
28
  <details>
21
29
  <summary>0.2.2</summary>
22
30