Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Refactor sidebar label selector (go-gitea#32460)
  Fix mermaid diagram height when initially hidden (go-gitea#32457)
  Add reviewers selection to new pull request (go-gitea#32403)
  Fix issue sidebar (go-gitea#32455)
  Refactor language menu and dom utils (go-gitea#32450)
  Fix broken releases when re-pushing tags (go-gitea#32435)
  Refactor issue page info (go-gitea#32445)
  Split issue sidebar into small templates (go-gitea#32444)
  Only provide the commit summary for Discord webhook push events (go-gitea#32432)
  Add new event commit status creation and webhook implementation (go-gitea#27151)
  Support quote selected comments to reply (go-gitea#32431)
  Move AddCollabrator and CreateRepositoryByExample to service layer (go-gitea#32419)

# Conflicts:
#	templates/repo/issue/view_content/context_menu.tmpl
  • Loading branch information
zjjhot committed Nov 10, 2024
2 parents 3927178 + 58c634b commit 6e76bb8
Show file tree
Hide file tree
Showing 114 changed files with 2,102 additions and 1,765 deletions.
3 changes: 3 additions & 0 deletions models/perm/access_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ func ParseAccessMode(permission string, allowed ...AccessMode) AccessMode {
}
return util.Iif(slices.Contains(allowed, m), m, AccessModeNone)
}

// ErrInvalidAccessMode is returned when an invalid access mode is used
var ErrInvalidAccessMode = util.NewInvalidArgumentErrorf("Invalid access mode")
5 changes: 4 additions & 1 deletion modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,10 @@ func createLink(href, content, class string) *html.Node {
a := &html.Node{
Type: html.ElementNode,
Data: atom.A.String(),
Attr: []html.Attribute{{Key: "href", Val: href}},
Attr: []html.Attribute{
{Key: "href", Val: href},
{Key: "data-markdown-generated-content"},
},
}

if class != "" {
Expand Down
2 changes: 1 addition & 1 deletion modules/markup/html_codepreview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ func TestRenderCodePreview(t *testing.T) {
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
}
test("http://localhost:3000/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20", "<p><div>code preview</div></p>")
test("http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20", `<p><a href="http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20" rel="nofollow">http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20</a></p>`)
test("http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20", `<p><a href="http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20" data-markdown-generated-content="" rel="nofollow">http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20</a></p>`)
}
12 changes: 6 additions & 6 deletions modules/markup/html_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ func numericIssueLink(baseURL, class string, index int, marker string) string {

// link an HTML link
func link(href, class, contents string) string {
if class != "" {
class = " class=\"" + class + "\""
}

return fmt.Sprintf("<a href=\"%s\"%s>%s</a>", href, class, contents)
extra := ` data-markdown-generated-content=""`
extra += util.Iif(class != "", ` class="`+class+`"`, "")
return fmt.Sprintf(`<a href="%s"%s>%s</a>`, href, extra, contents)
}

var numericMetas = map[string]string{
Expand Down Expand Up @@ -353,7 +351,9 @@ func TestRender_FullIssueURLs(t *testing.T) {
Metas: localMetas,
}, []processor{fullIssuePatternProcessor}, strings.NewReader(input), &result)
assert.NoError(t, err)
assert.Equal(t, expected, result.String())
actual := result.String()
actual = strings.ReplaceAll(actual, ` data-markdown-generated-content=""`, "")
assert.Equal(t, expected, actual)
}
test("Here is a link https://git.osgeo.org/gogs/postgis/postgis/pulls/6",
"Here is a link https://git.osgeo.org/gogs/postgis/postgis/pulls/6")
Expand Down
16 changes: 12 additions & 4 deletions modules/markup/html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ func TestRender_CrossReferences(t *testing.T) {
Metas: localMetas,
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
actual := strings.TrimSpace(buffer)
actual = strings.ReplaceAll(actual, ` data-markdown-generated-content=""`, "")
assert.Equal(t, strings.TrimSpace(expected), actual)
}

test(
Expand Down Expand Up @@ -156,7 +158,9 @@ func TestRender_links(t *testing.T) {
},
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
actual := strings.TrimSpace(buffer)
actual = strings.ReplaceAll(actual, ` data-markdown-generated-content=""`, "")
assert.Equal(t, strings.TrimSpace(expected), actual)
}

oldCustomURLSchemes := setting.Markdown.CustomURLSchemes
Expand Down Expand Up @@ -267,7 +271,9 @@ func TestRender_email(t *testing.T) {
},
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(res))
actual := strings.TrimSpace(res)
actual = strings.ReplaceAll(actual, ` data-markdown-generated-content=""`, "")
assert.Equal(t, strings.TrimSpace(expected), actual)
}
// Text that should be turned into email link

Expand Down Expand Up @@ -616,7 +622,9 @@ func TestPostProcess_RenderDocument(t *testing.T) {
Metas: localMetas,
}, strings.NewReader(input), &res)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(res.String()))
actual := strings.TrimSpace(res.String())
actual = strings.ReplaceAll(actual, ` data-markdown-generated-content=""`, "")
assert.Equal(t, strings.TrimSpace(expected), actual)
}

// Issue index shouldn't be post processing in a document.
Expand Down
12 changes: 8 additions & 4 deletions modules/markup/markdown/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ func TestTotal_RenderWiki(t *testing.T) {
IsWiki: true,
}, sameCases[i])
assert.NoError(t, err)
assert.Equal(t, template.HTML(answers[i]), line)
actual := strings.ReplaceAll(string(line), ` data-markdown-generated-content=""`, "")
assert.Equal(t, answers[i], actual)
}

testCases := []string{
Expand All @@ -336,7 +337,8 @@ func TestTotal_RenderWiki(t *testing.T) {
IsWiki: true,
}, testCases[i])
assert.NoError(t, err)
assert.Equal(t, template.HTML(testCases[i+1]), line)
actual := strings.ReplaceAll(string(line), ` data-markdown-generated-content=""`, "")
assert.EqualValues(t, testCases[i+1], actual)
}
}

Expand All @@ -356,7 +358,8 @@ func TestTotal_RenderString(t *testing.T) {
Metas: localMetas,
}, sameCases[i])
assert.NoError(t, err)
assert.Equal(t, template.HTML(answers[i]), line)
actual := strings.ReplaceAll(string(line), ` data-markdown-generated-content=""`, "")
assert.Equal(t, answers[i], actual)
}

testCases := []string{}
Expand Down Expand Up @@ -996,7 +999,8 @@ space</p>
for i, c := range cases {
result, err := markdown.RenderString(&markup.RenderContext{Ctx: context.Background(), Links: c.Links, IsWiki: c.IsWiki}, input)
assert.NoError(t, err, "Unexpected error in testcase: %v", i)
assert.Equal(t, c.Expected, string(result), "Unexpected result in testcase %v", i)
actual := strings.ReplaceAll(string(result), ` data-markdown-generated-content=""`, "")
assert.Equal(t, c.Expected, actual, "Unexpected result in testcase %v", i)
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/markup/sanitizer_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (st *Sanitizer) createDefaultPolicy() *bluemonday.Policy {
"start", "summary", "tabindex", "target",
"title", "type", "usemap", "valign", "value",
"vspace", "width", "itemprop",
"data-markdown-generated-content",
}

generalSafeElements := []string{
Expand Down
48 changes: 0 additions & 48 deletions modules/repository/collaborator.go

This file was deleted.

Loading

0 comments on commit 6e76bb8

Please sign in to comment.