fix: correct HTML and color conversion in bug UI
Amolith
created 3 weeks ago
Fix invalid HTML syntax where status timeline footer tag was
incorrectly duplicated instead of being closed properly.
Add defensive conversion of RGBA color channels from 16-bit
(0-65535) to 8-bit (0-255) before formatting as CSS hex colors
to ensure valid color output for bug labels.
References: bug-7d32125
Change summary
pkg/web/templates/bug.html | 2 +-
pkg/web/webui_bugs.go | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
Detailed changes
@@ -49,7 +49,7 @@
<strong>{{.Author}}</strong> {{.Status}} the bug.
<footer>
<time datetime="{{.Timestamp | rfc3339}}">{{.Timestamp | formatDate}}</time>
- <footer>
+ </footer>
{{else if eq .Type "labels"}}
<strong>{{.Author}}</strong>
@@ -287,9 +287,13 @@ func findBugByHash(rc *cache.RepoCache, hash string) (*cache.BugCache, error) {
func labelToWebLabel(label common.Label) Label {
rgba := label.Color().RGBA()
+ // RGBA() returns 16-bit channels (0-65535), convert to 8-bit (0-255)
+ r8 := uint8(rgba.R >> 8)
+ g8 := uint8(rgba.G >> 8)
+ b8 := uint8(rgba.B >> 8)
return Label{
Name: label.String(),
- Color: fmt.Sprintf("#%02x%02x%02x", rgba.R, rgba.G, rgba.B),
+ Color: fmt.Sprintf("#%02x%02x%02x", r8, g8, b8),
}
}