Network renaming is case-insensitive #793

Open
opened 2026-10-05 04:44:41 +02:00 by adam · 4 comments
Owner

Discovered by changing the capitalisation for a network name within the web interface and resulted in Network [network] already exists message.

Discovered by changing the capitalisation for a network name within the web interface and resulted in `Network [network] already exists` message. <!-- github-sync-id:267453738 -->
Author
Owner

The error message is located in AddNetwork() where a case-insensitive search returns a "conflicting" network name with the original casing.

Looks like the call to AddNetwork() begins with a binary comparison in NetworkPage().

What if we make the binary comparison in NetworkPage() case-insensitive and set the network name to pick up capitalization modifications? It doesn't need to add a new network there since only the capitalization changed, it's still the same network name from a case-insensitive point-of-view.

if (!pNetwork || !pNetwork->GetName().Equals(sName)) {
    ...
} else {
    pNetwork->SetName(sName);
}
The error message is located in [`AddNetwork()`](https://github.com/znc/znc/blob/6cd80535c064e91155468e79f50fc1c3f3c0f3e5/src/User.cpp#L511) where a case-insensitive search returns a "conflicting" network name with the original casing. Looks like the call to `AddNetwork()` begins with [a binary comparison in `NetworkPage()`](https://github.com/znc/znc/blob/6cd80535c064e91155468e79f50fc1c3f3c0f3e5/modules/webadmin.cpp#L1080). What if we make the binary comparison in `NetworkPage()` case-insensitive and set the network name to pick up capitalization modifications? It doesn't need to add a new network there since only the capitalization changed, it's still the same network name from a case-insensitive point-of-view. ```c++ if (!pNetwork || !pNetwork->GetName().Equals(sName)) { ... } else { pNetwork->SetName(sName); } ``` <!-- github-comment-id:711325838 -->
Author
Owner

That probably works. Webadmin is not the only way to edit networks though. Also you'll need a test.

That probably works. Webadmin is not the only way to edit networks though. Also you'll need a test. <!-- github-comment-id:711369039 -->
Author
Owner

Okay, I got webadmin and /znc movenetwork. Are there other methods for renaming a network?

Okay, I got webadmin and `/znc movenetwork`. Are there other methods for renaming a network? <!-- github-comment-id:711426971 -->
Author
Owner

That's it

That's it <!-- github-comment-id:711445889 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#793