Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MXIDs with slashes (/) incorrectly rejected #288

Open
0x1a8510f2 opened this issue Nov 4, 2022 · 8 comments
Open

MXIDs with slashes (/) incorrectly rejected #288

0x1a8510f2 opened this issue Nov 4, 2022 · 8 comments

Comments

@0x1a8510f2
Copy link
Contributor

Per the spec, MXIDs are allowed to contain forward slashes (/). However, matrix.to rejects such MXIDs:

The localpart of a user ID is an opaque identifier for that user. It MUST NOT be empty, and MUST contain only the characters a-z, 0-9, ., _, =, -, and /.

image

@Zocker1999NET
Copy link
Contributor

Zocker1999NET commented Dec 11, 2022

this probably happens because the parser does split the fragment (except the common prefix) by / (for the event id) before checking where the local part ends:

const [identifier, eventId] = linkStr.split("/");

@ahmedakef
Copy link

this issue made me stop using https://cactus.chat/ in my static website and will instead use https://giscus.app/

@AsbjornOlling
Copy link

Maintainer of Cactus Comments here.
I was just made aware of this bug in matrix.to because a friend of mine has broken links on their blog because of it as well.
It seems to still be an issue.

@pombredanne
Copy link

We have likely the same issue:

If I "copy the room link" in Element Desktop (or Web too BTW), https://matrix.to/#/#aboutcode-org/fosdem-2024:gitter.im is the link copied

But this is a dead, invalid link. It should have been
https://app.gitter.im/#/room/#aboutcode-org/fosdem-2024:gitter.im

matrix.to does not redirect correctly rooms with a slash.

@pombredanne
Copy link

I am experiencing the same issue and I originally thought this was an Element problem. element-hq/element-desktop#1435 ... this makes life really difficult as the generated matrix.to links are useless and error out. So you cannot really share you room at all.

@pombredanne
Copy link

as @Zocker1999NET pointed out the split is the issue. Here is a simple excerpt:

function parseFragment(fragment) {
        let [linkStr, queryParamsStr] = fragment.split("?");
        linkStr = linkStr.slice(2);
        const [identifier, eventId] = linkStr.split("/");
        return {"identifier": identifier, "eventId": eventId};
    }
parseFragment("/#aboutcode-org/vulnerablecode:gitter.im")

returns:

Object { identifier: "aboutcode-org", eventId: "vulnerablecode:gitter.im" }

But should have returned:

Object { identifier: "aboutcode-org/vulnerablecode:gitter.im", eventId: "" }

Also I could not find a tests for this function... are they in another repository may be? 😇

@shadow-identity
Copy link

Neither unescaped (https://matrix.to/#/@it/sme:matrix.org) nor escaped (https://matrix.to/#/@it%2Fsme:matrix.org) links does not work.

@shadow-identity
Copy link

Also the error message is misleading because the URL is actually valid

> new URL('https://matrix.to/#/@it/sme:matrix.org')
> URL {
hash: "#/@it/sme:matrix.org"
host: "matrix.to"
hostname: "matrix.to"
href: "https://matrix.to/#/@it/sme:matrix.org"
origin: "https://matrix.to/"
password: ""
pathname: "/"
port: ""
protocol: "https:"
search: ""
searchParams: URLSearchParams(0)
username: ""
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants