diff --git a/changelog.d/999.bugfix b/changelog.d/999.bugfix new file mode 100644 index 000000000..4c9d4dfd3 --- /dev/null +++ b/changelog.d/999.bugfix @@ -0,0 +1 @@ +Fix bugs in handling server names that includes colons 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}`; 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) {