diff --git a/changelog.d/fixed-agent-channel-repos-esc.md b/changelog.d/fixed-agent-channel-repos-esc.md new file mode 100644 index 0000000000..cf88363662 --- /dev/null +++ b/changelog.d/fixed-agent-channel-repos-esc.md @@ -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)). diff --git a/src/pkg/dashboard/agent_channels_repos_esc_test.go b/src/pkg/dashboard/agent_channels_repos_esc_test.go new file mode 100644 index 0000000000..8d45b3493f --- /dev/null +++ b/src/pkg/dashboard/agent_channels_repos_esc_test.go @@ -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()") + } +} diff --git a/src/pkg/dashboard/static-src/js/config-agent.js b/src/pkg/dashboard/static-src/js/config-agent.js index ad63d03826..862066edd3 100644 --- a/src/pkg/dashboard/static-src/js/config-agent.js +++ b/src/pkg/dashboard/static-src/js/config-agent.js @@ -631,7 +631,7 @@ if (ch.patterns && ch.patterns.length) html += 'patterns: '+ch.patterns.map(p => ''+esc(p)+'').join(', '); if (ch.schedule) html += 'schedule: '+esc(ch.schedule)+''; if (ch.match) html += 'match: '+Object.entries(ch.match).map(([k,v]) => ''+esc(k)+'='+esc(v)+'').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 += ''; html += ''; html += ''; diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index d0fd0e460c..dcbf5d13fa 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -53788,7 +53788,7 @@

Hub settings

if (ch.patterns && ch.patterns.length) html += 'patterns: '+ch.patterns.map(p => ''+esc(p)+'').join(', '); if (ch.schedule) html += 'schedule: '+esc(ch.schedule)+''; if (ch.match) html += 'match: '+Object.entries(ch.match).map(([k,v]) => ''+esc(k)+'='+esc(v)+'').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 += ''; html += ''; html += '';