diff options
author | 2023-06-02 17:42:14 +0200 | |
---|---|---|
committer | 2023-06-02 17:42:14 +0200 | |
commit | 1f39275c0f4ff3356a480ef7f0339d54547968e5 (patch) | |
tree | 8ba20351dfc6b0f1a8caec4673ed658d7147b807 /internal | |
parent | [bugfix] Overwrite API client closed errors with `499 - Client Closed Request... (diff) | |
download | gotosocial-1f39275c0f4ff3356a480ef7f0339d54547968e5.tar.xz |
[bugfix] Allow lowercase emoji shortcode in frontend (#1851)
* Replace pinafore with semaphore
* Typo
* Allow lowercase emoji shortcode in frontend
* Fix failing test (corrected expected outcome)
Diffstat (limited to 'internal')
-rw-r--r-- | internal/api/client/admin/emojiupdate_test.go | 2 | ||||
-rw-r--r-- | internal/db/bundb/migrations/20211113114307_init/emoji.go | 2 | ||||
-rw-r--r-- | internal/db/bundb/migrations/20220905150505_custom_emoji_updates/emoji.go | 2 | ||||
-rw-r--r-- | internal/gtsmodel/emoji.go | 2 | ||||
-rw-r--r-- | internal/validate/formvalidation.go | 4 |
5 files changed, 6 insertions, 6 deletions
diff --git a/internal/api/client/admin/emojiupdate_test.go b/internal/api/client/admin/emojiupdate_test.go index 0fcf579ad..1f0e8de13 100644 --- a/internal/api/client/admin/emojiupdate_test.go +++ b/internal/api/client/admin/emojiupdate_test.go @@ -473,7 +473,7 @@ func (suite *EmojiUpdateTestSuite) TestEmojiUpdateCopyEmptyShortcode() { b, err := ioutil.ReadAll(result.Body) suite.NoError(err) - suite.Equal(`{"error":"Bad Request: shortcode did not pass validation, must be between 2 and 30 characters, lowercase letters, numbers, and underscores only"}`, string(b)) + suite.Equal(`{"error":"Bad Request: shortcode did not pass validation, must be between 2 and 30 characters, letters, numbers, and underscores only"}`, string(b)) } func (suite *EmojiUpdateTestSuite) TestEmojiUpdateCopyNoShortcode() { diff --git a/internal/db/bundb/migrations/20211113114307_init/emoji.go b/internal/db/bundb/migrations/20211113114307_init/emoji.go index 68a808a16..0b9c871c8 100644 --- a/internal/db/bundb/migrations/20211113114307_init/emoji.go +++ b/internal/db/bundb/migrations/20211113114307_init/emoji.go @@ -24,7 +24,7 @@ type Emoji struct { ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database CreatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created UpdatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated - Shortcode string `validate:"required" bun:",nullzero,notnull,unique:shortcodedomain"` // String shortcode for this emoji -- the part that's between colons. This should be lowercase a-z_ eg., 'blob_hug' 'purple_heart' Must be unique with domain. + Shortcode string `validate:"required" bun:",nullzero,notnull,unique:shortcodedomain"` // String shortcode for this emoji -- the part that's between colons. This should be a-zA-Z_ eg., 'blob_hug' 'purple_heart' 'Gay_Otter' Must be unique with domain. Domain string `validate:"omitempty,fqdn" bun:",nullzero,default:'',unique:shortcodedomain"` // Origin domain of this emoji, eg 'example.org', 'queer.party'. empty string for local emojis. ImageRemoteURL string `validate:"required_without=ImageURL,omitempty,url" bun:",nullzero"` // Where can this emoji be retrieved remotely? Null for local emojis. ImageStaticRemoteURL string `validate:"required_without=ImageStaticURL,omitempty,url" bun:",nullzero"` // Where can a static / non-animated version of this emoji be retrieved remotely? Null for local emojis. diff --git a/internal/db/bundb/migrations/20220905150505_custom_emoji_updates/emoji.go b/internal/db/bundb/migrations/20220905150505_custom_emoji_updates/emoji.go index b1c982547..857f333d1 100644 --- a/internal/db/bundb/migrations/20220905150505_custom_emoji_updates/emoji.go +++ b/internal/db/bundb/migrations/20220905150505_custom_emoji_updates/emoji.go @@ -24,7 +24,7 @@ type Emoji struct { ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database CreatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created UpdatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated - Shortcode string `validate:"required" bun:",nullzero,notnull,unique:domainshortcode"` // String shortcode for this emoji -- the part that's between colons. This should be lowercase a-z_ eg., 'blob_hug' 'purple_heart' Must be unique with domain. + Shortcode string `validate:"required" bun:",nullzero,notnull,unique:domainshortcode"` // String shortcode for this emoji -- the part that's between colons. This should be a-zA-Z_ eg., 'blob_hug' 'purple_heart' 'Gay_Otter' Must be unique with domain. Domain string `validate:"omitempty,fqdn" bun:",nullzero,unique:domainshortcode"` // Origin domain of this emoji, eg 'example.org', 'queer.party'. empty string for local emojis. ImageRemoteURL string `validate:"required_without=ImageURL,omitempty,url" bun:",nullzero"` // Where can this emoji be retrieved remotely? Null for local emojis. ImageStaticRemoteURL string `validate:"required_without=ImageStaticURL,omitempty,url" bun:",nullzero"` // Where can a static / non-animated version of this emoji be retrieved remotely? Null for local emojis. diff --git a/internal/gtsmodel/emoji.go b/internal/gtsmodel/emoji.go index 16c7b3bee..1e21c7d1e 100644 --- a/internal/gtsmodel/emoji.go +++ b/internal/gtsmodel/emoji.go @@ -24,7 +24,7 @@ type Emoji struct { ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database CreatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created UpdatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated - Shortcode string `validate:"required" bun:",nullzero,notnull,unique:domainshortcode"` // String shortcode for this emoji -- the part that's between colons. This should be lowercase a-z_ eg., 'blob_hug' 'purple_heart' Must be unique with domain. + Shortcode string `validate:"required" bun:",nullzero,notnull,unique:domainshortcode"` // String shortcode for this emoji -- the part that's between colons. This should be a-zA-Z_ eg., 'blob_hug' 'purple_heart' 'Gay_Otter' Must be unique with domain. Domain string `validate:"omitempty,fqdn" bun:",nullzero,unique:domainshortcode"` // Origin domain of this emoji, eg 'example.org', 'queer.party'. empty string for local emojis. ImageRemoteURL string `validate:"required_without=ImageURL,omitempty,url" bun:",nullzero"` // Where can this emoji be retrieved remotely? Null for local emojis. ImageStaticRemoteURL string `validate:"required_without=ImageStaticURL,omitempty,url" bun:",nullzero"` // Where can a static / non-animated version of this emoji be retrieved remotely? Null for local emojis. diff --git a/internal/validate/formvalidation.go b/internal/validate/formvalidation.go index c122bf2bc..c4028ec66 100644 --- a/internal/validate/formvalidation.go +++ b/internal/validate/formvalidation.go @@ -179,10 +179,10 @@ func CustomCSS(customCSS string) error { // EmojiShortcode just runs the given shortcode through the regular expression // for emoji shortcodes, to figure out whether it's a valid shortcode, ie., 2-30 characters, -// lowercase a-z, numbers, and underscores. +// a-zA-Z, numbers, and underscores. func EmojiShortcode(shortcode string) error { if !regexes.EmojiShortcode.MatchString(shortcode) { - return fmt.Errorf("shortcode %s did not pass validation, must be between 2 and 30 characters, lowercase letters, numbers, and underscores only", shortcode) + return fmt.Errorf("shortcode %s did not pass validation, must be between 2 and 30 characters, letters, numbers, and underscores only", shortcode) } return nil } |