Repository navigation
π fix(stories): cap the prefilled issue URL by encoded bytes, not UTF-16 chars - #263
Conversation
β¦-16 chars Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
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 inm(trimEndand the surrogate guard only remove trailing units), sobuildIssue(data).length <= URL_MAXis monotone and the search converges on the longest fitting cut.encodeURIComponentoutput is pure ASCII, so.lengthof the URL equals its byte count β the "bytes, not UTF-16" claim holds.markdown()(stories/index.html:392β406) readsdata.story_full, whichcollectDataWithtakes 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_truncatedbranch (stories/index.html:542β553);story_url_trimmedonly swaps the wording. - Ran
node --test scripts/story-dialog.test.mjson 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
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