gitbucket / gitbucket

A Git platform powered by Scala with easy installation, high extensibility & GitHub API compatibility
https://gitbucket.github.io/
Apache License 2.0
9.16k stars 1.25k forks source link

Integration with Slack sends message with broken link if branch name has a slash character #1510

Open nbkhope opened 7 years ago

nbkhope commented 7 years ago

Issue

Impacted version: 4.9.0

Problem description: Every time I push a branch to GitBucket, a notification message is posted on a Slack channel. That message has a link that points to the branch. If the branch name has a slash character, like feature/some-branch-name, the link is broken because the slash becomes a %2F. To illustrate that, using the JavaScript encodeURI & encodeURIComponent functions:

console.log(encodeURI('feature/do-something')) VM161:1 feature/do-something

console.log(encodeURIComponent('feature/do-something')) VM167:1 feature%2Fdo-something

I'm not sure exactly whose problem this is -- of GitBucket or of Slack. Whoever is creating the link seems to be encoding the slash in the branch name to %2F.

Message in Slack:

github APP [9:46 AM] 
[some-repository:feature/do-something] (<-- broken link) 1 new commit by Some One:
`52a9b52` Add missing parameters to main function - Some One

LINK: https://www.some.where/gitbucket/some-group/some-repository/tree/feature%2Fdo-something

ghost commented 7 years ago

@nbkhope Slack does the URL encoding, but this is usually not a problem. Are you running GitBucket behind an HTTP server? As an example, Apache's mod_rewrite have troublesome problems such as multiple URL encoding.