@character-foundry/character-foundry 0.4.2-dev.1765942273 → 0.4.2-dev.1765997746

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/voxta.js CHANGED
@@ -7212,6 +7212,22 @@ function sanitizeName(name, ext) {
7212
7212
  if (!safeName) safeName = "asset";
7213
7213
  return safeName;
7214
7214
  }
7215
+ function sanitizeExtension(ext) {
7216
+ const normalized = ext.trim().replace(/^\./, "").toLowerCase();
7217
+ if (!normalized) {
7218
+ throw new Error("Invalid asset extension: empty extension");
7219
+ }
7220
+ if (normalized.length > 64) {
7221
+ throw new Error(`Invalid asset extension: too long (${normalized.length} chars)`);
7222
+ }
7223
+ if (normalized.includes("/") || normalized.includes("\\") || normalized.includes("\0")) {
7224
+ throw new Error("Invalid asset extension: path separators are not allowed");
7225
+ }
7226
+ if (!/^[a-z0-9][a-z0-9._-]*$/.test(normalized)) {
7227
+ throw new Error(`Invalid asset extension: "${ext}"`);
7228
+ }
7229
+ return normalized;
7230
+ }
7215
7231
  function writeVoxta(card, assets, options = {}) {
7216
7232
  const { compressionLevel = 6, includePackageJson = false } = options;
7217
7233
  const cardData = card.data;
@@ -7300,8 +7316,9 @@ function writeVoxta(card, assets, options = {}) {
7300
7316
  let assetCount = 0;
7301
7317
  let mainThumbnail;
7302
7318
  for (const asset of assets) {
7303
- const safeName = sanitizeName(asset.name, asset.ext);
7304
- const finalFilename = `${safeName}.${asset.ext}`;
7319
+ const safeExt = sanitizeExtension(asset.ext);
7320
+ const safeName = sanitizeName(asset.name, safeExt);
7321
+ const finalFilename = `${safeName}.${safeExt}`;
7305
7322
  let voxtaPath = "";
7306
7323
  const tags = asset.tags || [];
7307
7324
  const isMainIcon = asset.type === "icon" && (tags.includes("portrait-override") || asset.name === "main" || asset.isMain);