Skip to content

Commit 810335f

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Run editorconfig-checker on `locale_en-US.ini` (go-gitea#29608) bump protobuf module (go-gitea#29617) Add ac claim for old docker/build-push-action@v3 / current buildx gha cache (go-gitea#29584) Skip email domain check when admins edit user emails (go-gitea#29609) Improve natural sort (go-gitea#29611) Add empty repo check in `DetectAndHandleSchedules` (go-gitea#29606) Fix contributor graphs mobile layout and responsiveness (go-gitea#29597) Skip email domain check when admin users adds user manually (go-gitea#29522) Replace more `gt-` with `tw-`, update frontend docs (go-gitea#29595) Remove unnecessary ctxData for "attachments" template (go-gitea#29600) Adjust tailwind content globs (go-gitea#29596) Use flex wrap to layout the PR update button (go-gitea#29590) Make "/user/login" page redirect if the current user has signed in (go-gitea#29583) [skip ci] Updated translations via Crowdin Fix projects mode bugs (go-gitea#29593) Regenerate fomantic lockfile and build it with our browserslist (go-gitea#29560) Do not exceed display for the PR page buttons on smaller screens (go-gitea#29418) Add aria-label to the navbar menu button (go-gitea#29587)
2 parents 79032d9 + c481dba commit 810335f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1644
-929
lines changed

.github/workflows/files-changed.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
- "Makefile"
4949
- ".golangci.yml"
5050
- ".editorconfig"
51+
- "options/locale/locale_en-US.ini"
5152
5253
frontend:
5354
- "**/*.js"

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ GO_DIRS := build cmd models modules routers services tests
147147
WEB_DIRS := web_src/js web_src/css
148148

149149
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github
150+
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
150151

151152
GO_SOURCES := $(wildcard *.go)
152153
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
@@ -426,7 +427,7 @@ lint-go-vet:
426427

427428
.PHONY: lint-editorconfig
428429
lint-editorconfig:
429-
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .github/workflows
430+
@$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES)
430431

431432
.PHONY: lint-actions
432433
lint-actions:
@@ -908,6 +909,7 @@ fomantic:
908909
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
909910
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
910911
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
912+
$(SED_INPLACE) -e 's/ overrideBrowserslist\r/ overrideBrowserslist: ["defaults"]\r/g' $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/tasks/config/tasks.js
911913
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
912914
# fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
913915
$(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js

docs/content/contributing/guidelines-frontend.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h
4747
9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided.
4848
10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event.
4949
11. Custom event names are recommended to use `ce-` prefix.
50-
12. Gitea's tailwind-style CSS classes use `gt-` prefix (`gt-relative`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
50+
12. Prefer using Tailwind CSS which is available via `tw-` prefix, e.g. `tw-relative`. Gitea's helper CSS classes use `gt-` prefix (`gt-df`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
5151
13. Avoid inline scripts & styles as much as possible, it's recommended to put JS code into JS files and use CSS classes. If inline scripts & styles are unavoidable, explain the reason why it can't be avoided.
5252

5353
### Accessibility / ARIA

docs/content/contributing/guidelines-frontend.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ HTML 页面由[Go HTML Template](https://pkg.go.dev/html/template)渲染。
4747
9. 避免在 CSS 中使用不必要的`!important`,如果无法避免,添加注释解释为什么需要它。
4848
10. 避免在一个事件监听器中混合不同的事件,优先为每个事件使用独立的事件监听器。
4949
11. 推荐使用自定义事件名称前缀`ce-`
50-
12. Gitea 的 tailwind-style CSS 类使用`gt-`前缀(`gt-relative`),Gitea 自身的私有框架级 CSS 类使用`g-`前缀(`g-modal-confirm`)。
50+
12. 建议使用 Tailwind CSS,它可以通过 `tw-` 前缀获得,例如 `tw-relative`. Gitea 自身的助手类 CSS 使用 `gt-` 前缀(`gt-df`),Gitea 自身的私有框架级 CSS 类使用 `g-` 前缀(`g-modal-confirm`)。
5151
13. 尽量避免内联脚本和样式,建议将JS代码放入JS文件中并使用CSS类。如果内联脚本和样式不可避免,请解释无法避免的原因。
5252

5353
### 可访问性 / ARIA

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ require (
113113
golang.org/x/text v0.14.0
114114
golang.org/x/tools v0.17.0
115115
google.golang.org/grpc v1.60.1
116-
google.golang.org/protobuf v1.32.0
116+
google.golang.org/protobuf v1.33.0
117117
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
118118
gopkg.in/ini.v1 v1.67.0
119119
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
13081308
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
13091309
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
13101310
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1311-
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
1312-
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
1311+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
1312+
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
13131313
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
13141314
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
13151315
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

models/fixtures/repo_unit.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@
520520
id: 75
521521
repo_id: 1
522522
type: 8
523-
config: "{\"ProjectsMode\":\"all\"}"
524523
created_unix: 946684810
525524

526525
-

models/repo/repo.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,11 @@ func (repo *Repository) MustGetUnit(ctx context.Context, tp unit.Type) *RepoUnit
412412
Config: new(ActionsConfig),
413413
}
414414
} else if tp == unit.TypeProjects {
415+
cfg := new(ProjectsConfig)
416+
cfg.ProjectsMode = ProjectsModeNone
415417
return &RepoUnit{
416418
Type: tp,
417-
Config: new(ProjectsConfig),
419+
Config: cfg,
418420
}
419421
}
420422

models/repo/repo_unit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (cfg *ProjectsConfig) GetProjectsMode() ProjectsMode {
236236
return cfg.ProjectsMode
237237
}
238238

239-
return ProjectsModeNone
239+
return ProjectsModeAll
240240
}
241241

242242
func (cfg *ProjectsConfig) IsProjectsAllowed(m ProjectsMode) bool {

models/user/email_address.go

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,37 +154,18 @@ func UpdateEmailAddress(ctx context.Context, email *EmailAddress) error {
154154

155155
var emailRegexp = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
156156

157-
// ValidateEmail check if email is a allowed address
157+
// ValidateEmail check if email is a valid & allowed address
158158
func ValidateEmail(email string) error {
159-
if len(email) == 0 {
160-
return ErrEmailInvalid{email}
161-
}
162-
163-
if !emailRegexp.MatchString(email) {
164-
return ErrEmailCharIsNotSupported{email}
165-
}
166-
167-
if email[0] == '-' {
168-
return ErrEmailInvalid{email}
169-
}
170-
171-
if _, err := mail.ParseAddress(email); err != nil {
172-
return ErrEmailInvalid{email}
173-
}
174-
175-
// if there is no allow list, then check email against block list
176-
if len(setting.Service.EmailDomainAllowList) == 0 &&
177-
validation.IsEmailDomainListed(setting.Service.EmailDomainBlockList, email) {
178-
return ErrEmailInvalid{email}
179-
}
180-
181-
// if there is an allow list, then check email against allow list
182-
if len(setting.Service.EmailDomainAllowList) > 0 &&
183-
!validation.IsEmailDomainListed(setting.Service.EmailDomainAllowList, email) {
184-
return ErrEmailInvalid{email}
159+
if err := validateEmailBasic(email); err != nil {
160+
return err
185161
}
162+
return validateEmailDomain(email)
163+
}
186164

187-
return nil
165+
// ValidateEmailForAdmin check if email is a valid address when admins manually add or edit users
166+
func ValidateEmailForAdmin(email string) error {
167+
return validateEmailBasic(email)
168+
// In this case we do not need to check the email domain
188169
}
189170

190171
func GetEmailAddressByEmail(ctx context.Context, email string) (*EmailAddress, error) {
@@ -534,3 +515,41 @@ func ActivateUserEmail(ctx context.Context, userID int64, email string, activate
534515

535516
return committer.Commit()
536517
}
518+
519+
// validateEmailBasic checks whether the email complies with the rules
520+
func validateEmailBasic(email string) error {
521+
if len(email) == 0 {
522+
return ErrEmailInvalid{email}
523+
}
524+
525+
if !emailRegexp.MatchString(email) {
526+
return ErrEmailCharIsNotSupported{email}
527+
}
528+
529+
if email[0] == '-' {
530+
return ErrEmailInvalid{email}
531+
}
532+
533+
if _, err := mail.ParseAddress(email); err != nil {
534+
return ErrEmailInvalid{email}
535+
}
536+
537+
return nil
538+
}
539+
540+
// validateEmailDomain checks whether the email domain is allowed or blocked
541+
func validateEmailDomain(email string) error {
542+
// if there is no allow list, then check email against block list
543+
if len(setting.Service.EmailDomainAllowList) == 0 &&
544+
validation.IsEmailDomainListed(setting.Service.EmailDomainBlockList, email) {
545+
return ErrEmailInvalid{email}
546+
}
547+
548+
// if there is an allow list, then check email against allow list
549+
if len(setting.Service.EmailDomainAllowList) > 0 &&
550+
!validation.IsEmailDomainListed(setting.Service.EmailDomainAllowList, email) {
551+
return ErrEmailInvalid{email}
552+
}
553+
554+
return nil
555+
}

0 commit comments

Comments
 (0)