mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
remove all case normalization for keys
From spec discussion, we will most likely either require keys to be lowercase, or else treat them as case-opaque, similar to message tag keys.
This commit is contained in:
parent
fa58f49b14
commit
7b696b2f20
1 changed files with 3 additions and 12 deletions
|
|
@ -3166,7 +3166,7 @@ func metadataRegisteredHandler(client *Client, config *Config, subcommand string
|
||||||
|
|
||||||
switch subcommand {
|
switch subcommand {
|
||||||
case "set":
|
case "set":
|
||||||
key := strings.ToLower(params[2])
|
key := params[2]
|
||||||
if metadataKeyIsEvil(key) {
|
if metadataKeyIsEvil(key) {
|
||||||
rb.Add(nil, server.name, "FAIL", "METADATA", "KEY_INVALID", utils.SafeErrorParam(key), client.t("Invalid key name"))
|
rb.Add(nil, server.name, "FAIL", "METADATA", "KEY_INVALID", utils.SafeErrorParam(key), client.t("Invalid key name"))
|
||||||
return
|
return
|
||||||
|
|
@ -3215,7 +3215,6 @@ func metadataRegisteredHandler(client *Client, config *Config, subcommand string
|
||||||
defer rb.EndNestedBatch(batchId)
|
defer rb.EndNestedBatch(batchId)
|
||||||
|
|
||||||
for _, key := range params[2:] {
|
for _, key := range params[2:] {
|
||||||
key = strings.ToLower(key)
|
|
||||||
if metadataKeyIsEvil(key) {
|
if metadataKeyIsEvil(key) {
|
||||||
rb.Add(nil, server.name, "FAIL", "METADATA", "KEY_INVALID", utils.SafeErrorParam(key), client.t("Invalid key name"))
|
rb.Add(nil, server.name, "FAIL", "METADATA", "KEY_INVALID", utils.SafeErrorParam(key), client.t("Invalid key name"))
|
||||||
continue
|
continue
|
||||||
|
|
@ -3316,18 +3315,10 @@ func metadataUnregisteredHandler(client *Client, config *Config, subcommand stri
|
||||||
// metadataSubsHandler handles subscription-related commands;
|
// metadataSubsHandler handles subscription-related commands;
|
||||||
// these are handled the same whether the client is registered or not
|
// these are handled the same whether the client is registered or not
|
||||||
func metadataSubsHandler(client *Client, subcommand string, params []string, rb *ResponseBuffer) (exiting bool) {
|
func metadataSubsHandler(client *Client, subcommand string, params []string, rb *ResponseBuffer) (exiting bool) {
|
||||||
allToLower := func(in []string) (out []string) {
|
|
||||||
out = make([]string, len(in))
|
|
||||||
for i, s := range in {
|
|
||||||
out[i] = strings.ToLower(s)
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
server := client.server
|
server := client.server
|
||||||
switch subcommand {
|
switch subcommand {
|
||||||
case "sub":
|
case "sub":
|
||||||
keys := allToLower(params[2:])
|
keys := params[2:]
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
if metadataKeyIsEvil(key) {
|
if metadataKeyIsEvil(key) {
|
||||||
rb.Add(nil, server.name, "FAIL", "METADATA", "KEY_INVALID", utils.SafeErrorParam(key), client.t("Invalid key name"))
|
rb.Add(nil, server.name, "FAIL", "METADATA", "KEY_INVALID", utils.SafeErrorParam(key), client.t("Invalid key name"))
|
||||||
|
|
@ -3349,7 +3340,7 @@ func metadataSubsHandler(client *Client, subcommand string, params []string, rb
|
||||||
}
|
}
|
||||||
|
|
||||||
case "unsub":
|
case "unsub":
|
||||||
keys := allToLower(params[2:])
|
keys := params[2:]
|
||||||
removed := rb.session.UnsubscribeFrom(keys...)
|
removed := rb.session.UnsubscribeFrom(keys...)
|
||||||
|
|
||||||
lineLength := MaxLineLen - len(server.name) - len(RPL_METADATAUNSUBOK) - len(client.Nick()) - 10
|
lineLength := MaxLineLen - len(server.name) - len(RPL_METADATAUNSUBOK) - len(client.Nick()) - 10
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue