Skip to content

πŸ› fix(stories): cap the prefilled issue URL by encoded bytes, not UTF-16 chars - #263

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-262
Oct 25, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-262

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

The 1500-char story cap counted UTF-16 units, but GitHub limits the encoded URL by bytes. CJK/emoji/accented stories at the cap produce 9–18 KB URLs.

Measured: ≀6 KB OK (302 to login), 6.5–8 KB β†’ 500 for signed-out visitors, >8 KB β†’ 414.

Change: keep STORY_MAX = 1500 for counter/soft cap; add URL_MAX = 6000 and binary-search the story cut until buildIssue(data).length ≀ URL_MAX (surrogate guard + trimEnd re-applied). A byte-budget cut sets story_truncated with a distinct notice; the clipboard markdown still carries the full story.

Tests: 1500 CJK chars submit within budget with prefix/no-lone-surrogate/notice; popup-blocked fallback obeys budget; clipboard keeps full story. CSP hash regenerated.

Closes #262

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

…-16 chars

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending β€” sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending β€” sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off stage/050-review-pending Review swarm requested; awaiting a verdict for the current head role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) labels Oct 25, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read stories/index.html at 36fb339 end to end, not just the diff. This looks correct to me.

  • collectData() (stories/index.html:431–446): the binary search is sound. cutStory(full, m) is a prefix whose length is non-decreasing in m (trimEnd and the surrogate guard only remove trailing units), so buildIssue(data).length <= URL_MAX is monotone and the search converges on the longest fitting cut. encodeURIComponent output is pure ASCII, so .length of the URL equals its byte count β€” the "bytes, not UTF-16" claim holds.
  • markdown() (stories/index.html:392–406) reads data.story_full, which collectDataWith takes straight from the textarea, so the clipboard really does keep the full story regardless of either cut.
  • Both notices route through the same data.story_truncated branch (stories/index.html:542–553); story_url_trimmed only swaps the wording.
  • Ran node --test scripts/story-dialog.test.mjs on the head: 31/31 pass. Recomputed the SHA-256 of the inline script: D+MA4Kw6ReaUtgOvUTEDy2F6wjHX8c9dgo723LdyqQA= matches the new CSP entry.

One non-blocking note: if the other fields alone exceed URL_MAX, the search bottoms out at an empty story and still emits an over-budget URL β€” same outcome as before this PR, so not a regression.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit f2b3020 into main Oct 25, 2026
6 of 7 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-262 branch October 25, 2026 10:05
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#26336fb339` sha256:f39f89c48c6ba7674d9b2b28420b54cd3ed62104a5f9ae1233408debe0c7c6c0 β€” download from the dashboard or `hivectl review evidence #263`.

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] stories: 1500-char cap is counted in UTF-16 units, non-ASCII stories overflow GitHub's URL limit (414/500)

0 participants