wgt-node-utils 1.2.4 → 1.2.7
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/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/index.js +46 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -722,5 +722,51 @@ class wgtNodeUtils {
|
|
|
722
722
|
};
|
|
723
723
|
}
|
|
724
724
|
};
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* 排除非法路径:检查字符串是否包含非法文件扩展或关键词
|
|
728
|
+
* @param {string} path - 要检查的路径字符串
|
|
729
|
+
* @returns {boolean} - 如果包含非法路径返回 true,否则返回 false
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
excludeIllegalPath = (path) => {
|
|
733
|
+
if (typeof path !== 'string') {
|
|
734
|
+
throw new Error("输入的字符串无效,请传入一个有效的字符串。");
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// 预定义的正则表达式(忽略大小写匹配敏感关键词)
|
|
738
|
+
const regex = /\.(php|env|xml|production|example)/i;
|
|
739
|
+
// 转为小写后检查是否匹配
|
|
740
|
+
return regex.test(path.toLowerCase());
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* 详情页面排除非法路径:检查字符串是否包含非法文件扩展、关键词、大写字母、特殊字符
|
|
745
|
+
* @param {string} path - 要检查的路径字符串
|
|
746
|
+
* @returns {boolean} - 如果包含非法路径返回 true,否则返回 false
|
|
747
|
+
*/
|
|
748
|
+
|
|
749
|
+
gameDetailExcludeIllegalPath = (path) => {
|
|
750
|
+
if (typeof path !== 'string') {
|
|
751
|
+
throw new Error("输入的字符串无效,请传入一个有效的字符串。");
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// 检查非法文件扩展和敏感关键词(忽略大小写)
|
|
755
|
+
const illegalPatterns = /\.(php|env|xml|production|example)/i;
|
|
756
|
+
|
|
757
|
+
// 检查是否包含大写字母(排除大写字母)
|
|
758
|
+
const hasUpperCase = /[A-Z]/;
|
|
759
|
+
|
|
760
|
+
// 检查是否包含特殊字符(除斜杠和下划线外)
|
|
761
|
+
const hasSpecialChar = /[^a-zA-Z0-9/_]/;
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
// 任意条件满足即为非法路径
|
|
765
|
+
return (
|
|
766
|
+
illegalPatterns.test(path) || // 检测非法文件扩展或关键词
|
|
767
|
+
hasUpperCase.test(path) || // 检测大写字母
|
|
768
|
+
hasSpecialChar.test(path) // 检测特殊字符
|
|
769
|
+
);
|
|
770
|
+
}
|
|
725
771
|
}
|
|
726
772
|
module.exports = new wgtNodeUtils('cli_a538bc45e770d00b', 'EDK1uleQyLym6WWDISo00dwx4gssiskJ');
|