Skip to content

Commit

Permalink
Do not show issue context popup on external issues
Browse files Browse the repository at this point in the history
The issues pop-up context cannot work for external issues - therefore do not show
these.

Fix go-gitea#17047

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath committed Sep 14, 2021
1 parent e2f0ab3 commit 99e3274
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
reftext := node.Data[ref.RefLocation.Start:ref.RefLocation.End]
if exttrack && !ref.IsPull {
ctx.Metas["index"] = ref.Issue
link = createLink(com.Expand(ctx.Metas["format"], ctx.Metas), reftext, "ref-issue")
link = createLink(com.Expand(ctx.Metas["format"], ctx.Metas), reftext, "ref-issue ref-external-issue")
} else {
// Path determines the type of link that will be rendered. It's unknown at this point whether
// the linked item is actually a PR or an issue. Luckily it's of no real consequence because
Expand Down
2 changes: 1 addition & 1 deletion modules/markup/sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func createDefaultPolicy() *bluemonday.Policy {
}

// Allow classes for anchors
policy.AllowAttrs("class").Matching(regexp.MustCompile(`ref-issue`)).OnElements("a")
policy.AllowAttrs("class").Matching(regexp.MustCompile(`ref-issue( ref-external-issue)?`)).OnElements("a")

// Allow classes for task lists
policy.AllowAttrs("class").Matching(regexp.MustCompile(`task-list-item`)).OnElements("li")
Expand Down
3 changes: 3 additions & 0 deletions web_src/js/features/contextpopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default function initContextPopups() {
if (!refIssues.length) return;

refIssues.each(function () {
if ($(this).hasClass('ref-external-issue')) {
return;
}
const [index, _issues, repo, owner] = $(this).attr('href').replace(/[#?].*$/, '').split('/').reverse();

const el = document.createElement('div');
Expand Down

0 comments on commit 99e3274

Please sign in to comment.