X Tutup
Skip to content

Commit 0327845

Browse files
committed
Escape workflow information when generating URLs
1 parent 2580a63 commit 0327845

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/cmd/workflow/view/view.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package view
33
import (
44
"fmt"
55
"net/http"
6+
"net/url"
67
"strings"
78

89
"github.com/MakeNowJust/heredoc"
@@ -101,7 +102,7 @@ func runView(opts *ViewOptions) error {
101102
}
102103

103104
if opts.Web {
104-
var url string
105+
var address string
105106
if opts.YAML {
106107
ref := opts.Ref
107108
if ref == "" {
@@ -112,14 +113,14 @@ func runView(opts *ViewOptions) error {
112113
return err
113114
}
114115
}
115-
url = ghrepo.GenerateRepoURL(repo, "blob/%s/%s", ref, workflow.Path)
116+
address = ghrepo.GenerateRepoURL(repo, "blob/%s/%s", url.QueryEscape(ref), url.QueryEscape(workflow.Path))
116117
} else {
117-
url = ghrepo.GenerateRepoURL(repo, "actions/workflows/%s", workflow.Base())
118+
address = ghrepo.GenerateRepoURL(repo, "actions/workflows/%s", url.QueryEscape(workflow.Base()))
118119
}
119120
if opts.IO.IsStdoutTTY() {
120-
fmt.Fprintf(opts.IO.Out, "Opening %s in your browser.\n", utils.DisplayURL(url))
121+
fmt.Fprintf(opts.IO.Out, "Opening %s in your browser.\n", utils.DisplayURL(address))
121122
}
122-
return opts.Browser.Browse(url)
123+
return opts.Browser.Browse(address)
123124
}
124125

125126
if opts.YAML {

0 commit comments

Comments
 (0)
X Tutup