Skip to content

Commit 93704b3

Browse files
authored
Merge branch 'main' into previos-blame-link
2 parents 600e300 + 9a0cd3a commit 93704b3

File tree

4 files changed

+51
-20
lines changed

4 files changed

+51
-20
lines changed

models/login_source.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,25 @@ var (
7070
_ convert.Conversion = &SSPIConfig{}
7171
)
7272

73+
// jsonUnmarshalIgnoreErroneousBOM - due to a bug in xorm (see https://gitea.com/xorm/xorm/pulls/1957) - it's
74+
// possible that a Blob may gain an unwanted prefix of 0xff 0xfe.
75+
func jsonUnmarshalIgnoreErroneousBOM(bs []byte, v interface{}) error {
76+
json := jsoniter.ConfigCompatibleWithStandardLibrary
77+
err := json.Unmarshal(bs, &v)
78+
if err != nil && len(bs) > 2 && bs[0] == 0xff && bs[1] == 0xfe {
79+
err = json.Unmarshal(bs[2:], &v)
80+
}
81+
return err
82+
}
83+
7384
// LDAPConfig holds configuration for LDAP login source.
7485
type LDAPConfig struct {
7586
*ldap.Source
7687
}
7788

7889
// FromDB fills up a LDAPConfig from serialized format.
7990
func (cfg *LDAPConfig) FromDB(bs []byte) error {
80-
json := jsoniter.ConfigCompatibleWithStandardLibrary
81-
err := json.Unmarshal(bs, &cfg)
91+
err := jsonUnmarshalIgnoreErroneousBOM(bs, &cfg)
8292
if err != nil {
8393
return err
8494
}
@@ -119,8 +129,7 @@ type SMTPConfig struct {
119129

120130
// FromDB fills up an SMTPConfig from serialized format.
121131
func (cfg *SMTPConfig) FromDB(bs []byte) error {
122-
json := jsoniter.ConfigCompatibleWithStandardLibrary
123-
return json.Unmarshal(bs, cfg)
132+
return jsonUnmarshalIgnoreErroneousBOM(bs, cfg)
124133
}
125134

126135
// ToDB exports an SMTPConfig to a serialized format.
@@ -137,8 +146,7 @@ type PAMConfig struct {
137146

138147
// FromDB fills up a PAMConfig from serialized format.
139148
func (cfg *PAMConfig) FromDB(bs []byte) error {
140-
json := jsoniter.ConfigCompatibleWithStandardLibrary
141-
return json.Unmarshal(bs, &cfg)
149+
return jsonUnmarshalIgnoreErroneousBOM(bs, cfg)
142150
}
143151

144152
// ToDB exports a PAMConfig to a serialized format.
@@ -159,8 +167,7 @@ type OAuth2Config struct {
159167

160168
// FromDB fills up an OAuth2Config from serialized format.
161169
func (cfg *OAuth2Config) FromDB(bs []byte) error {
162-
json := jsoniter.ConfigCompatibleWithStandardLibrary
163-
return json.Unmarshal(bs, cfg)
170+
return jsonUnmarshalIgnoreErroneousBOM(bs, cfg)
164171
}
165172

166173
// ToDB exports an SMTPConfig to a serialized format.
@@ -180,8 +187,7 @@ type SSPIConfig struct {
180187

181188
// FromDB fills up an SSPIConfig from serialized format.
182189
func (cfg *SSPIConfig) FromDB(bs []byte) error {
183-
json := jsoniter.ConfigCompatibleWithStandardLibrary
184-
return json.Unmarshal(bs, cfg)
190+
return jsonUnmarshalIgnoreErroneousBOM(bs, cfg)
185191
}
186192

187193
// ToDB exports an SSPIConfig to a serialized format.

models/repo_unit.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ type UnitConfig struct{}
2828

2929
// FromDB fills up a UnitConfig from serialized format.
3030
func (cfg *UnitConfig) FromDB(bs []byte) error {
31-
json := jsoniter.ConfigCompatibleWithStandardLibrary
32-
return json.Unmarshal(bs, &cfg)
31+
return jsonUnmarshalIgnoreErroneousBOM(bs, &cfg)
3332
}
3433

3534
// ToDB exports a UnitConfig to a serialized format.
@@ -45,8 +44,7 @@ type ExternalWikiConfig struct {
4544

4645
// FromDB fills up a ExternalWikiConfig from serialized format.
4746
func (cfg *ExternalWikiConfig) FromDB(bs []byte) error {
48-
json := jsoniter.ConfigCompatibleWithStandardLibrary
49-
return json.Unmarshal(bs, &cfg)
47+
return jsonUnmarshalIgnoreErroneousBOM(bs, &cfg)
5048
}
5149

5250
// ToDB exports a ExternalWikiConfig to a serialized format.
@@ -64,8 +62,7 @@ type ExternalTrackerConfig struct {
6462

6563
// FromDB fills up a ExternalTrackerConfig from serialized format.
6664
func (cfg *ExternalTrackerConfig) FromDB(bs []byte) error {
67-
json := jsoniter.ConfigCompatibleWithStandardLibrary
68-
return json.Unmarshal(bs, &cfg)
65+
return jsonUnmarshalIgnoreErroneousBOM(bs, &cfg)
6966
}
7067

7168
// ToDB exports a ExternalTrackerConfig to a serialized format.
@@ -83,8 +80,7 @@ type IssuesConfig struct {
8380

8481
// FromDB fills up a IssuesConfig from serialized format.
8582
func (cfg *IssuesConfig) FromDB(bs []byte) error {
86-
json := jsoniter.ConfigCompatibleWithStandardLibrary
87-
return json.Unmarshal(bs, &cfg)
83+
return jsonUnmarshalIgnoreErroneousBOM(bs, &cfg)
8884
}
8985

9086
// ToDB exports a IssuesConfig to a serialized format.
@@ -107,8 +103,7 @@ type PullRequestsConfig struct {
107103

108104
// FromDB fills up a PullRequestsConfig from serialized format.
109105
func (cfg *PullRequestsConfig) FromDB(bs []byte) error {
110-
json := jsoniter.ConfigCompatibleWithStandardLibrary
111-
return json.Unmarshal(bs, &cfg)
106+
return jsonUnmarshalIgnoreErroneousBOM(bs, &cfg)
112107
}
113108

114109
// ToDB exports a PullRequestsConfig to a serialized format.

templates/repo/diff/conversation.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
</ui>
2828
</div>
2929
<div class="df je ac fw mt-3">
30+
<div class="ui buttons mr-2">
31+
<button class="ui icon tiny basic button previous-conversation">
32+
{{svg "octicon-arrow-up"}} {{$.i18n.Tr "repo.issues.previous"}}
33+
</button>
34+
<button class="ui icon tiny basic button next-conversation">
35+
{{svg "octicon-arrow-down"}} {{$.i18n.Tr "repo.issues.next"}}
36+
</button>
37+
</div>
3038
{{if and $.CanMarkConversation $isNotPending}}
3139
<button class="ui icon tiny basic button resolve-conversation" data-origin="diff" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index .comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation">
3240
{{if $resolved}}

web_src/js/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,28 @@ async function initRepository() {
942942
action: 'hide'
943943
});
944944

945+
// Previous/Next code review conversation
946+
$(document).on('click', '.previous-conversation', (e) => {
947+
const $conversation = $(e.currentTarget).closest('.comment-code-cloud');
948+
const $conversations = $('.comment-code-cloud:not(.hide)');
949+
const index = $conversations.index($conversation);
950+
if (index !== 0) {
951+
const $previousConversation = $conversations.eq(index - 1);
952+
const anchor = $previousConversation.find('.comment').first().attr('id');
953+
window.location.href = `#${anchor}`;
954+
}
955+
});
956+
$(document).on('click', '.next-conversation', (e) => {
957+
const $conversation = $(e.currentTarget).closest('.comment-code-cloud');
958+
const $conversations = $('.comment-code-cloud:not(.hide)');
959+
const index = $conversations.index($conversation);
960+
if (index !== $conversations.length - 1) {
961+
const $nextConversation = $conversations.eq(index + 1);
962+
const anchor = $nextConversation.find('.comment').first().attr('id');
963+
window.location.href = `#${anchor}`;
964+
}
965+
});
966+
945967
// Quote reply
946968
$(document).on('click', '.quote-reply', function (event) {
947969
$(this).closest('.dropdown').find('.menu').toggle('visible');

0 commit comments

Comments
 (0)