From 5324637d193a4c37f5276498bb5b089de74e3af2 Mon Sep 17 00:00:00 2001 From: Twilight Sparkle <19155609+Twi1ightSparkle@users.noreply.github.com> Date: Wed, 11 Dec 2024 12:49:10 +0000 Subject: [PATCH 1/5] Only split userId on the first colon --- src/Connections/GenericHook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Connections/GenericHook.ts b/src/Connections/GenericHook.ts index 2f0e831f7..17ed8e3b0 100644 --- a/src/Connections/GenericHook.ts +++ b/src/Connections/GenericHook.ts @@ -334,7 +334,7 @@ export class GenericHookConnection extends BaseConnection implements IConnection if (!this.config.userIdPrefix) { return this.intent.userId; } - const [, domain] = this.intent.userId.split(':'); + const domain = this.intent.userId.substring(this.intent.userId.indexOf(':')+1); const name = this.state.name && this.state.name.replace(/[A-Z]/g, (s) => s.toLowerCase()).replace(/([^a-z0-9\-.=_]+)/g, ''); return `@${this.config.userIdPrefix}${name || 'bot'}:${domain}`; From caca3b1d34ed5c70f991e2715e3f1488f89352f2 Mon Sep 17 00:00:00 2001 From: Twilight Sparkle <19155609+Twi1ightSparkle@users.noreply.github.com> Date: Wed, 11 Dec 2024 12:56:34 +0000 Subject: [PATCH 2/5] Add changelog --- changelog.d/999.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/999.bugfix diff --git a/changelog.d/999.bugfix b/changelog.d/999.bugfix new file mode 100644 index 000000000..244c936a0 --- /dev/null +++ b/changelog.d/999.bugfix @@ -0,0 +1 @@ +Fix bug where generic hooks doesn't work when the server name has the port in it From cfdb42023b9eac4cbfcfe5fcbd5bed9b294f10d6 Mon Sep 17 00:00:00 2001 From: Twilight Sparkle <19155609+Twi1ightSparkle@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:11:14 +0000 Subject: [PATCH 3/5] Update changelog to also account for IPv6 --- changelog.d/999.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/999.bugfix b/changelog.d/999.bugfix index 244c936a0..7df74d4f9 100644 --- a/changelog.d/999.bugfix +++ b/changelog.d/999.bugfix @@ -1 +1 @@ -Fix bug where generic hooks doesn't work when the server name has the port in it +Fix bug where generic hooks doesn't work when the server name includes a colon From 29b9b54c221b990e69abfe78528b8d055de51d95 Mon Sep 17 00:00:00 2001 From: Twilight Sparkle <19155609+Twi1ightSparkle@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:07:18 +0000 Subject: [PATCH 4/5] Fix split in permissions --- src/config/permissions.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/config/permissions.rs b/src/config/permissions.rs index 63997a191..938dc92f1 100644 --- a/src/config/permissions.rs +++ b/src/config/permissions.rs @@ -100,12 +100,10 @@ impl BridgePermissions { service: String, permission: String, ) -> napi::Result { - let parts: Vec<&str> = mxid.split(':').collect(); let permission_int = permission_level_to_int(permission)?; - let domain = if parts.len() > 1 { - parts[1].to_string() - } else { - parts[0].to_string() + let domain: String = match mxid.split_once(':') { + Some((.., d)) => d.to_string(), + None => return Ok(false), }; for actor_permission in self.config.iter() { // Room_id @@ -128,12 +126,10 @@ impl BridgePermissions { #[napi] pub fn check_action_any(&self, mxid: String, permission: String) -> napi::Result { - let parts: Vec<&str> = mxid.split(':').collect(); let permission_int = permission_level_to_int(permission)?; - let domain = if parts.len() > 1 { - parts[1].to_string() - } else { - parts[0].to_string() + let domain: String = match mxid.split_once(':') { + Some((.., d)) => d.to_string(), + None => return Ok(false), }; for actor_permission in self.config.iter() { if !self.match_actor(actor_permission, &domain, &mxid) { From bd1b180e1e2cbb1fad9b0a073f136b33ca74b849 Mon Sep 17 00:00:00 2001 From: Twilight Sparkle <19155609+Twi1ightSparkle@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:10:54 +0000 Subject: [PATCH 5/5] Update changelog to reflect permissions fix as well --- changelog.d/999.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/999.bugfix b/changelog.d/999.bugfix index 7df74d4f9..4c9d4dfd3 100644 --- a/changelog.d/999.bugfix +++ b/changelog.d/999.bugfix @@ -1 +1 @@ -Fix bug where generic hooks doesn't work when the server name includes a colon +Fix bugs in handling server names that includes colons