-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix(NcReferenceList): check if text contains valid URL before resolving #5290
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this will not work as
URL_PATTERN
matches only full URLs, not relative or absolute URLs without a location.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you lead me to the place in Text, and give a way to reproduce it with relative URLs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact the whole idea of #5272 was to turn relative links (e.g.
../Target
) and absolute links (e.g./index.php/apps/collectives/Garden/Watering
) into full URLs with a location before they're matched againstURL_PATTERN
😬Could you provide an example text of what is passed to
NcReferenceList
as propertytext
which breaks currently?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test message
- it tries to resolve a link:https://nextcloud.local/index.php/call/test%20message
test message with a link https://nextcloud.local/index.php/call/w38mo5vy
- same:https://nextcloud.local/index.php/call/test%20message%20with%20a%20link%20https://nextcloud.local/index.php/call/w38mo5vy
https://nextcloud.local/index.php/call/w38mo5vy
- resolves correctly../apps/spreed
- creates a reference to an app rootThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could replace URL_PATTERN with some combination RELATIVE_URL_PATTERN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be an option to sanitize the links inside Talk and make sure to only pass valid URLs to
NcReferenceList
?Given that we cannot distinguish between valid relative links and mere text I only see two paths forward:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could work if use something like
^(\.){1,2}\/.*
as regex forRELATIVE_URL_PATTERN
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's library issue, not Talk. NcRichText passes complete text
That would be preferred, I guess. It was not expected before #5272 to render references for relative links, I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean one of these places?
https://github.com/nextcloud/text/blob/35be559ca27f384cd80e9e5fe76ee739c7c754e6/src/nodes/ParagraphView.vue#L105-L112
https://github.com/nextcloud/text/blob/35be559ca27f384cd80e9e5fe76ee739c7c754e6/src/components/Link/LinkBubbleView.vue#L148-L155
If yes, then I believe, it's totally doable on Text app side. NcReferenceWidget itself is capable to handle links within app by itself (see
getRoute()
method in autolink.js)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, both probably. I'm fine with trying to handle this in Text. So let's revert my earlier PR and I'll look into it in Text.