Title: id(web): file-list tag pill truncation panics on a multi-byte character straddling byte 256 — templates.rs slices &v[..256] off-boundary · Issue #815 · developing-today/code · GitHub
Open Graph Title: id(web): file-list tag pill truncation panics on a multi-byte character straddling byte 256 — templates.rs slices &v[..256] off-boundary · Issue #815 · developing-today/code
X Title: id(web): file-list tag pill truncation panics on a multi-byte character straddling byte 256 — templates.rs slices &v[..256] off-boundary · Issue #815 · developing-today/code
Description: Problem The web file list's tag-pill rendering truncates long tag values with a raw byte slice that panics when the cut point falls inside a multi-byte UTF-8 character — taking down the file-list request for any file carrying such a tag....
Open Graph Description: Problem The web file list's tag-pill rendering truncates long tag values with a raw byte slice that panics when the cut point falls inside a multi-byte UTF-8 character — taking down the file-list r...
X Description: Problem The web file list's tag-pill rendering truncates long tag values with a raw byte slice that panics when the cut point falls inside a multi-byte UTF-8 character — taking down the file-li...
Opengraph URL: https://github.com/developing-today/code/issues/815
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web): file-list tag pill truncation panics on a multi-byte character straddling byte 256 — templates.rs slices &v[..256] off-boundary","articleBody":"## Problem\n\nThe web file list's tag-pill rendering truncates long tag values with a raw byte slice that **panics** when the cut point falls inside a multi-byte UTF-8 character — taking down the file-list request for any file carrying such a tag.\n\n`pkgs/id/src/web/templates.rs:261-265` (`render_file_list`):\n\n```rust\nlet truncated = if v.len() > crate::tags::TAG_DISPLAY_MAX_BYTES { // 256\n format!(\"{}…\", &v[..crate::tags::TAG_DISPLAY_MAX_BYTES])\n} else {\n v.clone()\n};\n```\n\n`&v[..256]` panics with `byte index 256 is not a char boundary` whenever byte 256 is mid-character. Tag values are user-controlled (set from the CLI, the bulk-tag UI, or synced from peers) and reach this code via `get_file_list` → `FileInfo.tags` (`routes.rs`), so one crafted/accidental tag value makes `/files` (and the `/api/files` partial) fail for that file list.\n\n## Repro (verified on main `1161bcff`)\n\nVerbatim harness of the two lines above with `v = \"a\"×255 + \"é\" + \"tail-tail-tail\"` (length 269 > 256; `é` occupies bytes 255..257):\n\n```\nthread 'main' panicked at trunc.rs:5:38:\nend byte index 256 is not a char boundary; it is inside 'é' (bytes 255..257 of string)\n```\n\nAny value longer than 256 bytes whose byte-256 offset splits a 2–4-byte character triggers it (e.g. an emoji or CJK character at that offset, or a long CJK/accented value).\n\n## The safe helper already exists in the same crate\n\n`pkgs/id/src/commands/tag.rs:90-100` defines `pub fn truncate_on_char_boundary(s: &str, max: usize) -> String`, which walks back to a char boundary before slicing — and its tests already cover exactly this shape (`tag.rs:407`: a value with `é` straddling the limit). The web template re-implemented the truncation inline and missed the boundary walk.\n\n## Suggested fix\n\nIn `templates.rs`, replace the inline slice with the existing helper:\n\n```rust\nlet truncated = crate::commands::tag::truncate_on_char_boundary(v, crate::tags::TAG_DISPLAY_MAX_BYTES);\n```\n\n(`truncate_on_char_boundary` returns the string unchanged when it fits, so the `if` can go.) Add a regression test rendering a file list whose tag value has a multi-byte character straddling byte 256, asserting the pill shows the boundary-truncated value + `…` and nothing panics.\n\n## Acceptance criteria\n\n- [ ] Rendering a file list containing a >256-byte tag value with a multi-byte character straddling byte 256 does not panic and shows the value truncated on a char boundary with `…`.\n- [ ] Values ≤256 bytes and pure-ASCII long values render exactly as before.\n- [ ] The web template uses the crate's existing `truncate_on_char_boundary` (no second inline implementation).\n- [ ] New regression test in the web templates tests; `cargo test --features web` web template tests pass.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-24T22:23:59Z","url":"https://github.com/developing-today/code/issues/815"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:04569964-a92c-5e7a-06e8-69daed9668eb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE2C:23E430:B1EF61:E5D66F:6B063968 |
| html-safe-nonce | 9d46cbc8df660fda4b87432070de250253084d579cab6d88539df0db23f9fd68 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTJDOjIzRTQzMDpCMUVGNjE6RTVENjZGOjZCMDYzOTY4IiwidmlzaXRvcl9pZCI6IjUxODU3NzMyOTE5OTQyMzMxOTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 48d6abad9a5099befe17e9c5107fba84e3fd0bd5cbce99936bc0e40a47dcf3ad |
| hovercard-subject-tag | issue:6018261465 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/815/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1851912977cea00ba888abd1b6bddfc499a86ddd298a3b7eda9859ecbd2f2a14/developing-today/code/issues/815 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1851912977cea00ba888abd1b6bddfc499a86ddd298a3b7eda9859ecbd2f2a14/developing-today/code/issues/815 |
| og:image:alt | Problem The web file list's tag-pill rendering truncates long tag values with a raw byte slice that panics when the cut point falls inside a multi-byte UTF-8 character — taking down the file-list r... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | dcf72c457c022486d23c3cbb0dd21aba537a87611ca9ddabd1799cf2eaa9b297 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0f38f5735226749ec5e08a8649dce4cb2613d9ad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width