Skip to content

fix(view): strip the emitted first-page prefix in paginationLinks(prependOnFirst=false) - #3666

Merged
bpamiri merged 1 commit into
developfrom
claude/wheels-framework-bug-review-odsc9d-pagination-prepend
Sep 27, 2026
Merged

bpamiri merged 1 commit into
developfrom
claude/wheels-framework-bug-review-odsc9d-pagination-prepend

Conversation

@bpamiri

@bpamiri bpamiri commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

With prependOnFirst=false, legacy paginationLinks() stripped Len(arguments.prependToPage) characters from the start of the page window. But the first page is not preceded by the raw argument. It gets the sanitized prependToPage (numeric entities decoded, on* handlers stripped), or its active variant when that page is the current one and addActiveClassToPrependedParent=true. Whenever the lengths differ, the first link is mangled. The sibling appendOnLast branch already uses the sanitized length.

Fix: the per-page prefix logic moves into a new public helper, $paginationPrependForPage(), which the window loop and the strip now share. The strip works out the first page in the window (Max(1, currentPage - windowSize), matching the loop's lower bound). It then removes that exact prefix, and only if Left() actually matches it.

Related Issue

None filed. Found during a framework bug review.

Type of Change

  • Bug fix

Feature Completeness Checklist

  • DCO sign-off
  • Tests: 3 cases in view/linksSpec.cfc: the active-class prefix, encode=true markup with numeric entities, and a stripped onclick handler.
  • Changelog fragment: changelog.d/pagination-links-prepend-on-first.fixed.md
  • Test runner passes: CI is the first full-suite run.

Test Plan

I extracted paginationLinks, $paginationWindowMiddle, $paginationAnchorLink and the real sanitize/decode helpers verbatim and ran them on Lucee 6.2 through JSR-223. linkTo/pagination were stubbed, and EncodeForHTML was replaced with an ESAPI-style encoder. Old → new:

  • A — <li class="page-item">, active class on, page 1 current, encode=false: -item">1</li>… → 1</li><li class="page-item">…
  • B — encode=true, <li class='page-item'>, page 2: /a>&lt;/li&gt;… → <a href="?page=1">1</a>…
  • C — <li onclick="x()">: =1">1</a></li>… → <a href="?page=1">1</a></li>…
  • Controls: a plain <li>, the default prependOnFirst, and the active class on a later page produce identical output before and after.

🤖 Generated with Claude Code

https://claude.ai/code/session_018RdXpVKos1AZ24dM4X8wL1


Generated by Claude Code

…pendOnFirst=false)

paginationLinks() removed Len(arguments.prependToPage) characters from the front of the
window when prependOnFirst=false, but the first page is actually prefixed with the
sanitized prependToPage (entity-decoded, event handlers stripped) or, when it is the
current page and addActiveClassToPrependedParent=true, a variant with "active " injected.
Any length difference cut into or left behind part of the markup, e.g. a leading
`-item">1</li>`.

Extract the per-page prefix into $paginationPrependForPage() so the window loop and the
prependOnFirst strip share it, and strip that exact string (only when it matches) instead
of the raw argument length, mirroring the appendOnLast branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RdXpVKos1AZ24dM4X8wL1
Signed-off-by: Claude <noreply@anthropic.com>
@bpamiri
bpamiri merged commit d16a0dd into develop Sep 27, 2026
15 checks passed
@bpamiri
bpamiri deleted the claude/wheels-framework-bug-review-odsc9d-pagination-prepend branch September 27, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants