Skip to content

fix: decode multi-encoded block filenames - #17

Merged
JonasJesus42 merged 1 commit into
mainfrom
fix/blocks-dedup-multi-encoded
Mar 17, 2026
Merged

JonasJesus42 merged 1 commit into
mainfrom
fix/blocks-dedup-multi-encoded

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix decodeBlockName in generate-blocks.ts to decode recursively until stable, instead of only twice
  • Prevents duplicate blocks when .deco/blocks/ contains triple/quadruple-encoded filenames (e.g. %252520 for a space)

Problem

The .deco/blocks/ directory can accumulate filenames with multiple encoding levels:

Level Example Count (casaevideo)
Plain Frete Grátis.json 252
Single Frete%20Gr%C3%A1tis.json 267
Double Frete%2520Gr%25C3%25A1tis.json 11
Triple Frete%252520Gr%2525C3%2525A1tis.json 235
Quadruple Frete%25252520...json 55

The previous decodeURIComponent(decodeURIComponent(filename)) only handled up to double-encoded. Triple+ survived as separate blocks with %XX keys in the output.

Impact on casaevideo: 55 duplicate blocks, .decofile response inflated from ~11MB to ~20MB, admin.deco.cx crashed trying to load the site.

Fix

Decode in a loop (max 10 iterations) until the string stabilizes:

function decodeBlockName(filename: string): string {
  const base = filename.replace(/\.json$/, "");
  let decoded = base;
  for (let i = 0; i < 10; i++) {
    const next = decodeURIComponent(decoded);
    if (next === decoded) break;
    decoded = next;
  }
  return decoded;
}

Test plan

  • Verified all encoding levels resolve to the same key
  • Regenerated casaevideo blocks: 390 → 335 blocks, 20MB → 10.85MB
  • Zero URL-encoded keys remaining in output

🤖 Generated with Claude Code


Summary by cubic

Decode multi-encoded block filenames in .deco/blocks/ to merge duplicates and remove %XX keys. This shrinks the generated output and prevents admin crashes on sites with triple+ encoded files.

  • Bug Fixes
    • Updated decodeBlockName in scripts/generate-blocks.ts to repeatedly decode while % remains and the value changes, stopping on stability or invalid escapes.
    • Deduplicates triple/quadruple-encoded names (e.g., %252520), reducing casaevideo blocks 390→335 and .decofile size 20MB→10.85MB.

Written for commit 8d429e3. Summary will update on new commits.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/generate-blocks.ts">

<violation number="1" location="scripts/generate-blocks.ts:27">
P1: The recursive decode loop can throw on valid filenames that decode to a literal `%` (for example `100%2525.json`). After reaching `100%`, the next iteration calls `decodeURIComponent` again and aborts the generator with `URI malformed`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread scripts/generate-blocks.ts Resolved
@JonasJesus42
JonasJesus42 force-pushed the fix/blocks-dedup-multi-encoded branch from c244d39 to 7a70044 Compare March 17, 2026 01:10
The .deco/blocks/ directory can contain filenames with multiple levels
of URL encoding (e.g. %252520 = triple-encoded space). The previous
double-decode missed these, producing duplicate blocks with %XX keys
in the output. For casaevideo this inflated .decofile from ~11MB to
~20MB, causing the admin to fail loading the site.

Decode recursively while the string still contains % characters.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@JonasJesus42
JonasJesus42 force-pushed the fix/blocks-dedup-multi-encoded branch from 7a70044 to 8d429e3 Compare March 17, 2026 01:11
@JonasJesus42
JonasJesus42 merged commit a8efc3d into main Mar 17, 2026
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.25.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

guitavano added a commit that referenced this pull request Nov 17, 2026
…anStack Start, esbuild) (#832)

Closes the open Dependabot alerts in one PR, with the lockfile. The
Dependabot PRs (#811, #828, #747) only touch `package.json`, so they all
fail `bun install --frozen-lockfile` in CI.

| Package | From | To | Alerts |
|---|---|---|---|
| `react-server-dom-webpack` (tanstack-rsc-smoke) | 19.2.7 | 19.2.9 |
#19, critical: RSC RCE, GHSA-xqc2-xf4c-x3h3 |
| `react` / `react-dom` (all pinned workspaces) | 19.2.7 | 19.2.9 | peer
floor of the above |
| `next` (nextjs, compat-v7, nextjs-binding-smoke) | 16.3.8 | 16.4.6 |
#10–12, #14, #15, #17, #18, #20–22 |
| `@tanstack/react-start` (tanstack, compat-v7, smokes) | 1.168.58 |
1.168.61 | #2–4, #7, #9 |
| `@tanstack/react-router` | 1.170.39 | 1.170.42 | the version
react-start 1.168.61 pins, so it stays a single copy |
| `esbuild` (blocks, tanstack, compat-v7) | ^0.27.3 | ^0.28.2 | #5, #6,
#8 (low) |

`bun.lock` was regenerated with bun 1.3.5 (the `packageManager`). React
dedupes to a single 19.2.9 at the root, with no nested copies. Vite
still has its own transitive `[email protected]` (its own range); that is
outside our manifests.

Supersedes #811, #828 and #747.

### Verified locally (bun 1.3.5, node 24)
- `bun install --frozen-lockfile` ✅
- `bun run typecheck` ✅ · `bun run lint` ✅
- `bun x vitest run`: 3388 passed, 0 failed ✅ (includes
`tests/release.test.ts`)
- `examples/tanstack-worker-smoke`: build + smoke ✅
- `examples/nextjs-binding-smoke`: build + smoke ✅
- `examples/tanstack-rsc-smoke`: build + typecheck ✅

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Bumps several dependencies to clear open Dependabot security alerts,
including a critical RCE in `react-server-dom-webpack`
(GHSA-xqc2-xf4c-x3h3). The lockfile was regenerated so `bun install
--frozen-lockfile` passes — React dedupes to a single 19.2.9 copy.

**Dependencies**
- `react`, `react-dom`, and `react-server-dom-webpack` 19.2.7 → 19.2.9
- `next` 16.3.8 → 16.4.6
- `@tanstack/react-start` 1.168.58 → 1.168.61, with
`@tanstack/react-router` 1.170.42
- `esbuild` ^0.27.3 → ^0.28.2; Vite's own transitive `[email protected]` is
untouched
- Typecheck, lint, the full test suite (3388 passed), and the Next.js
and TanStack smoke builds all pass

<sup>Written for commit 123acc8.
Summary will update on new commits.</sup>

<a href="https://cubic.dev/pr/decocms/blocks/pull/832?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/decocms/blocks/832?returnTo=https%3A%2F%2Fgithub.com%2Fdecocms%2Fblocks%2Fpull%2F832&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant