Skip to content

Commit

Permalink
Fix issuetype calls adding URL escaping
Browse files Browse the repository at this point in the history
It is valid within JIRA to have issue types with spaces (for example we use
"Pro-Active Task") however the issuetype variable is not escaped prior to
formatting into the uri string.

This fix imports "net/url" and escapes all inclusions of issuetype into uri.
The only other variables formatted into uri are c.endpoint and issue which
shouldn't contain special characters.
  • Loading branch information
Jonathan Wright committed Feb 1, 2016
1 parent 47e9467 commit e4a25e2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"golang.org/x/crypto/ssh/terminal"
"net/http"
"net/http/httputil"
"net/url"
"os"
"strings"
// "github.com/kr/pretty"
Expand Down Expand Up @@ -181,7 +182,7 @@ func (c *Cli) CmdCreateMeta() error {
issuetype := c.getOptString("issuetype", "Bug")

log.Debug("createMeta called")
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", c.endpoint, project, issuetype)
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", c.endpoint, project, url.QueryEscape(issuetype))
data, err := responseToJson(c.get(uri))
if err != nil {
return err
Expand Down Expand Up @@ -227,7 +228,7 @@ func (c *Cli) CmdCreate() error {
issuetype := c.getOptString("issuetype", "Bug")
log.Debug("create called")

uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", c.endpoint, project, issuetype)
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", c.endpoint, project, url.QueryEscape(issuetype))
data, err := responseToJson(c.get(uri))
if err != nil {
return err
Expand Down

0 comments on commit e4a25e2

Please sign in to comment.