Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/http/endpoints/api/panel/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"regexp"
"strings"
"time"
"unicode/utf8"

"github.com/TicketsBot-cloud/dashboard/app"
"github.com/TicketsBot-cloud/dashboard/app/http/validation"
Expand Down Expand Up @@ -151,16 +152,15 @@ func validateEmoji(c PanelValidationContext) validation.ValidationFunc {
return validation.NewInvalidInputError("Emoji name mismatch")
}
} else {
// Convert from :emoji: to unicode if we need to
// Validate Unicode emoji
name := strings.TrimSpace(emoji.Name)
name = strings.Replace(name, ":", "", -1)

unicode, ok := utils.GetEmoji(name)
if !ok {
// Must be valid UTF-8
if !utf8.ValidString(name) {
return validation.NewInvalidInputError("Invalid emoji")
}

emoji.Name = unicode
emoji.Name = name
}

return nil
Expand Down
2 changes: 0 additions & 2 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ func main() {
utils.ArchiverClient = archiverclient.NewArchiverClient(archiverclient.NewProxyRetriever(config.Conf.Bot.ObjectStore), []byte(config.Conf.Bot.AesKey))
utils.SecureProxyClient = secureproxy.NewSecureProxy(config.Conf.SecureProxyUrl)

utils.LoadEmoji()

i18n.Init()

if config.Conf.Bot.ProxyUrl != "" {
Expand Down
12 changes: 12 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dependencies": {
"axios": "^0.21.4",
"dotenv": "^16.5.0",
"emoji-regex": "^10.6.0",
"sirv-cli": "^1.0.0",
"svelte-emoji-selector": "^1.0.1",
"svelte-router-spa": "^6.0.3",
Expand Down
12 changes: 4 additions & 8 deletions frontend/src/components/manage/PanelCreationForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import AccessControlList from "./AccessControlList.svelte";
import { DOCS_URL } from "../../js/constants";
import SupportHoursForm from "./SupportHoursForm.svelte";
import emojiRegex from "emoji-regex";

export let guildId;
export let seedDefault = true;
Expand All @@ -40,16 +41,11 @@

let lastCustomEmoji = undefined;
let lastUnicodeEmoji = "📩";
// Unicode emoji regex
const unicodeEmojiRegex = /^\p{Emoji}$/u;

function validateUnicodeEmoji(value) {
if (value === "") return true;
if (typeof value !== "string") return false;
if (/^<a?:\w+:\d+>$/.test(value)) return false;
// Disallow spaces
if (/\s/.test(value)) return false;
// Only allow if matches single unicode emoji
return unicodeEmojiRegex.test(value);
const matches = value.match(emojiRegex());
return matches !== null && matches.length === 1 && matches[0] === value;
}

// Replace spaces with dashes in naming scheme as the user types
Expand Down
Loading