Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Ignore permalink_prefix when serializing pills #11726

Merged
merged 8 commits into from
Aug 1, 2024

Conversation

herkulessi
Copy link
Contributor

@herkulessi herkulessi commented Oct 9, 2023

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

fixes element-hq/element-web/issues/26002

During serialization of messages, pills were wrongfully serialized to a URL
starting with permalink_prefix. This is against the Spec (which mandates
https://matrix.to/#/ links) and the resulting pills were not recognized as
pills in other clients.

Spec-Appendix concerning matrix.to links: https://spec.matrix.org/v1.8/appendices/#matrixto-navigation

Signed-off-by: Lars Wickel [email protected]


This PR currently has none of the required changelog labels.

A reviewer can add one of: T-Deprecation, T-Enhancement, T-Defect, T-Task to indicate what type of change this is, or add Type: [enhancement/defect/task] to the description and I'll add them for you.

@herkulessi herkulessi requested a review from a team as a code owner October 9, 2023 18:05
@github-actions github-actions bot added the Z-Community-PR Issue is solved by a community member's PR label Oct 9, 2023
public forEvent(roomId: string, eventId: string, serverCandidates: string[]): string {
public forEvent(roomId: string, eventId: string, serverCandidates: string[], ispill = false): string {
if (ispill) {
return `https://matrix.to/#/${roomId}/${eventId}${this.encodeServerCandidates(serverCandidates)}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is already generated by MatrixToPermalinkConstructor. I think probably the right fix here would be to pass the flag into makeGenericPermalink but then have getPermalinkConstructor() return the matrix.to one instead. This should make this change a lot simpler as all the various methods of the different PermalinkConstructor classes won't need the extra param.

@@ -269,26 +269,26 @@ export class RoomPermalinkCreator {
};
}

export function makeGenericPermalink(entityId: string): string {
return getPermalinkConstructor().forEntity(entityId);
export function makeGenericPermalink(entityId: string, ispill = false): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the param follow the code style & be camelCased to isPill please? I think I read it asm, "I spill" the first time, and that's in the context of this PR.

Also this function could really benefit from some doc now it's not just a simple single-parameter function, as it's not really obvious how the isPill parameter changes the function's behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where/How should I document that? A separate file in docs/ seems a bit overkill...
Just as comments in the source?

Copy link
Member

@dbkr dbkr Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, a jsdoc comment is perfect (eg.

/**
* Transforms an entity (permalink, room alias, user ID, etc) into a local URL
* if possible. If it is already a permalink (matrix.to) it gets returned
* unchanged.
* @param {string} entity The entity to transform.
* @returns {string|null} The transformed permalink or null if unable.
*/
)

herkulessi added 5 commits June 8, 2024 13:13
fixes element-hq/element-web/issues/26002

During serialization of messages, pills were wrongfully serialized to a URL
starting with `permalink_prefix`. This is against the Spec (which mandates
https://matrix.to/#/ links) and the resulting pills were not recognized as
pills in other clients.

Spec-Appendix concerning matrix.to links: https://spec.matrix.org/v1.8/appendices/#matrixto-navigation

Signed-off-by: Lars Wickel <[email protected]>
Signed-off-by: Lars Wickel <[email protected]>
Signed-off-by: Lars Wickel <[email protected]>
@herkulessi herkulessi force-pushed the fix-premalink_prefix-pills branch from bbe4618 to ba11663 Compare June 8, 2024 11:45
@t3chguy t3chguy requested a review from dbkr June 17, 2024 07:55
@dbkr dbkr added the T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems label Aug 1, 2024
Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, sorry for missing the update on this. (Also, please don't force-push PRs: it breaks all GitHub's review features).

@dbkr dbkr added this pull request to the merge queue Aug 1, 2024
Merged via the queue into matrix-org:develop with commit fa60edf Aug 1, 2024
26 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mentions shouldn't follow permalink_prefix
2 participants