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

[stable26] Use the href of links for link previews, not node.textContent #3886

Merged
merged 2 commits into from
Mar 8, 2023

Conversation

backportbot-nextcloud[bot]
Copy link

backport of #3873

@backportbot-nextcloud backportbot-nextcloud bot added the bug Something isn't working label Mar 3, 2023
@backportbot-nextcloud backportbot-nextcloud bot added this to the Nextcloud 26 milestone Mar 3, 2023
@cypress
Copy link

cypress bot commented Mar 3, 2023

2 flaky tests on run #8955 ↗︎

0 141 0 0 Flakiness 2

Details:

[stable26] Use the href of links for link previews, not `node.textContent`
Project: Text Commit: 8a4975b845
Status: Passed Duration: 04:08 💡
Started: Mar 8, 2023 10:22 AM Ended: Mar 8, 2023 10:27 AM
Flakiness  sync.spec.js • 1 flaky test

View Output Video

Test Artifacts
Sync > recovers from a lost connection Output Screenshots
Flakiness  share.spec.js • 1 flaky test

View Output Video

Test Artifacts
Open test.md in viewer > Share a file with download disabled shows an error Output Screenshots

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

Until now we used node.textContent to determine whether a paragraph is
a link that warrants a link preview. Instead, we now check whether the
paragraph has a single text node wich is a link and use its href.

Text nodes with empty textContent are ignored in order to allow
whitespaces before and after the link.

This way we ensure to always show the preview of the link target, not of
the description text. Both may differ, which has security implications.

Also, links with a custom description get a link preview as well.

And last but not least, it fixes link previes for URLs with spaces.
(Background: for some reason, url-encoded spaces in textContent of links
get decoded when they're transformed to markdown and written to a file.
Therefore URLs with spaces lost their link preview once the Text session
was closed prior to this commit)

Fixes: #3871

Signed-off-by: Jonas <jonas@freesources.org>
@mejo- mejo- force-pushed the backport/3873/stable26 branch from af8c4b3 to b13859e Compare March 8, 2023 10:00
@mejo-
Copy link
Member

mejo- commented Mar 8, 2023

/compile

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@juliusknorr juliusknorr merged commit 98326b1 into stable26 Mar 8, 2023
@delete-merged-branch delete-merged-branch bot deleted the backport/3873/stable26 branch March 8, 2023 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants