资产处理脚本中硬编码的开发者本地路径、不存在的源引用以及整数溢出
作者: codeCraft-Ritik创建于 2026年9月12日更新于 2026年9月12日
1. Hardcoded Local Machine Absolute Paths
In scripts/process-readme-buttons.mjs:
// Line 5
const srcDir = "C:/Users/User/Downloads";
const mapping = [
{ src: "ChatGPT Image Jun 17, 2026, 04_04_16 PM (1).png", out: "btn-site.png" },
// ...
];
In scripts/process-sponsor-badge.mjs and scripts/convert-readme-assets-webp.mjs:
const src = "C:/Users/User/Downloads/c4f8c4a7-2566-4644-b752-b652e0c103f5.png";
const jfif = "C:/Users/User/Downloads/6b610a0c-8889-49fc-9684-e172d7172ea0.jfif";
- The Problem: The scripts hardcode absolute file paths to a specific user account (
C:/Users/User/Downloads/) and transient filenames from local ChatGPT image downloads. - Symptom: The scripts fail immediately on any other machine, operating system (macOS/Linux), or CI/CD workflow with unhandled
Error: Input file is missing.
2. Referencing Non-Existent Source Files
In scripts/convert-readme-assets-webp.mjs:
const pngToWebp = [
"assets/readme-banner.png",
"assets/readme-buttons/btn-site.png",
"assets/readme-buttons/btn-mit.png",
"assets/readme-buttons/btn-agent-skills.png",
"assets/readme-buttons/btn-tools.png",
"assets/readme-buttons/btn-changelog.png",
];
- The Problem: Only
.webpimages were committed to the repository; none of the referenced.pngsource files exist underassets/. - Symptom: Running the script throws on the first iteration:
[Error: Input file is missing: .../assets/readme-banner.png].
3. Mathematical Integer Underflow in getBounds()
In convert-readme-assets-webp.mjs and process-readme-buttons.mjs:
function getBounds(rgba, width, height) {
let minX = width;
let minY = height;
let maxX = 0;
let maxY = 0;
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const a = rgba[(y * width + x) * 4 + 3];
if (a > 8) {
minX = Math.min(minX, x);
minY = Math.min(minY,
…
内容来源: Leonxlnx/taste-skill