Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-agent-channel-repos-esc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The agent channels list now escapes repository names before rendering them, matching the other channel fields ([#15907](https://github.com/hivecommons/hive/issues/15907)).
16 changes: 16 additions & 0 deletions src/pkg/dashboard/agent_channels_repos_esc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dashboard

import (
"strings"
"testing"
)

func TestAgentChannelsReposEscaped(t *testing.T) {
html := indexHTML(t)
if !strings.Contains(html, "ch.repos.map(esc).join(', ')") {
t.Fatal("channel repos must be escaped before rendering")
}
if strings.Contains(html, "ch.repos.join(', ')") {
t.Fatal("channel repos must not be joined without esc()")
}
}
2 changes: 1 addition & 1 deletion src/pkg/dashboard/static-src/js/config-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@
if (ch.patterns && ch.patterns.length) html += 'patterns: '+ch.patterns.map(p => '<code>'+esc(p)+'</code>').join(', ');
if (ch.schedule) html += 'schedule: <code>'+esc(ch.schedule)+'</code>';
if (ch.match) html += 'match: '+Object.entries(ch.match).map(([k,v]) => '<code>'+esc(k)+'='+esc(v)+'</code>').join(', ');
if (ch.repos && ch.repos.length) html += ' (repos: '+ch.repos.join(', ')+')';
if (ch.repos && ch.repos.length) html += ' (repos: '+ch.repos.map(esc).join(', ')+')';
html += '</div>';
html += '<label style="font-size:0.7rem;display:flex;align-items:center;gap:var(--sp-2);cursor:pointer"><input type="checkbox" '+(enabled?'checked':'')+disabled+' data-change-action="toggleChannel" data-arg0="'+i+'" data-arg-types="s,c"> on</label>';
html += '<button class="hv-btn btn-danger" data-action="removeChannel" data-arg0="'+i+'"'+disabled+'>✕</button>';
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53788,7 +53788,7 @@ <h4 class="settings-subsection-title">Hub settings</h4>
if (ch.patterns && ch.patterns.length) html += 'patterns: '+ch.patterns.map(p => '<code>'+esc(p)+'</code>').join(', ');
if (ch.schedule) html += 'schedule: <code>'+esc(ch.schedule)+'</code>';
if (ch.match) html += 'match: '+Object.entries(ch.match).map(([k,v]) => '<code>'+esc(k)+'='+esc(v)+'</code>').join(', ');
if (ch.repos && ch.repos.length) html += ' (repos: '+ch.repos.join(', ')+')';
if (ch.repos && ch.repos.length) html += ' (repos: '+ch.repos.map(esc).join(', ')+')';
html += '</div>';
html += '<label style="font-size:0.7rem;display:flex;align-items:center;gap:var(--sp-2);cursor:pointer"><input type="checkbox" '+(enabled?'checked':'')+disabled+' data-change-action="toggleChannel" data-arg0="'+i+'" data-arg-types="s,c"> on</label>';
html += '<button class="hv-btn btn-danger" data-action="removeChannel" data-arg0="'+i+'"'+disabled+'>✕</button>';
Expand Down
Loading