[MAGNOLIA-8931] rendering of RichTextField data fails if it contains a link which doesn't exist Created: 20/Jan/22 Updated: 19/Sep/23 Resolved: 07/Jun/23 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 6.3.0, 6.2.35 |
| Type: | Bug | Priority: | High |
| Reporter: | Tomáš Gregovský | Assignee: | Milan Divilek |
| Resolution: | Fixed | Votes: | 4 |
| Labels: | None | ||
| Σ Remaining Estimate: | Not Specified | Remaining Estimate: | Not Specified |
| Σ Time Spent: | 2.5h | Time Spent: | Not Specified |
| Σ Original Estimate: | Not Specified | Original Estimate: | Not Specified |
| Attachments: |
|
|||||||||||||||||||||||||
| Issue Links: |
|
|||||||||||||||||||||||||
| Sub-Tasks: |
|
|||||||||||||||||||||||||
| Template: |
|
|||||||||||||||||||||||||
| Acceptance criteria: |
Empty
|
|||||||||||||||||||||||||
| Task DoD: |
[X]*
Doc/release notes changes? Comment present?
[X]*
Downstream builds green?
[X]*
Solution information and context easily available?
[X]*
Tests
[X]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
|||||||||||||||||||||||||
| Bug DoR: |
[X]*
Steps to reproduce, expected, and actual results filled
[X]*
Affected version filled
|
|||||||||||||||||||||||||
| Date of First Response: | ||||||||||||||||||||||||||
| Epic Link: | Support | |||||||||||||||||||||||||
| Sprint: | DevX 39 | |||||||||||||||||||||||||
| Story Points: | 2 | |||||||||||||||||||||||||
| Team: | ||||||||||||||||||||||||||
| Work Started: | ||||||||||||||||||||||||||
| Approved: |
Yes
|
|||||||||||||||||||||||||
| Description |
| Comments |
| Comment by Roman Kovařík [ 04/Feb/22 ] |
|
Hey Could you explain what the relation between
<p>Some text with link <a href="${link:{uuid:{d17e1eba-ea6c-4b65-afd5-43fb28633eb5},repository:{website},path:{/international-programmes}}}">International Busines offering</a></p>
and
${cmsfn.decode(content).desc)
? (Seems like two complately unrelated things). Could you elaborate (the later is not a rich text field content).
Thanks in advance. Roman
|
| Comment by Tomáš Gregovský [ 09/Feb/22 ] |
|
hi rkovarik , first is what is saved in jcr if you use richtext, enter the text "Some text with link International Busines offering" and select few words to create an internal link ... the second is freemarker code to render such content (name of the field/property is 'desc' in this case) |
| Comment by Tomáš Gregovský [ 11/May/23 ] |
|
issue still happening on Magnolia 6.2.28, pls see my recording https://drive.google.com/file/d/1-qKHNcUXYJjIPfM39FMgTnJUz_yKUf1b/view?usp=sharing |
| Comment by Milan Divilek [ 26/May/23 ] |
|
To reproduce the issue, you need to remove i18n from the site definition of the page and you need to visit the site from different domain or subdomain. This then fails when it tries to resolve link in CrossSiteAbsolutePathTransformer on getting raw url from i18n which is not configured for site. Reproduce:
Investigation:When creating this link from the link pattern
${link:{uuid:{5d6384f7-f044-4194-a120-703aedf7c054},repository:{website},path:{/test/test-sub}}}
info.magnolia.link.LinkUtil#createLinkInstance tries to resolve node but it fails because it has no permission for it. This then leads to creation of info.magnolia.link.Link without jcrNode, workspace and path set. Then in info.magnolia.multisite.DomainNamePathTransformer#transform when resolving best URI2RepositoryMapping no mapping match because there's no workspace set in the link (if it's set then site mapping is resolved). This then leads to different behaviour when handlePrefix is not removed from the linkStr. So when you have permissions link is generated without site prefix, but when you don't have permission link is generated with site prefix. CrossSiteAbsolutePathTransformer#65-69 tries to remove site prefix from the link when it was already added by i18n to avoid doubling site prefix in url. If link contains site prefix it tries to get rawUri from i18n link and remove site prefix, but when i18n is not set this fails on NPE. Discovered problem with different link resolved when accessing page from configured domain for siteIn our example above we use sportstation.com domain for our test site. Visit page http://sportstation.com:8080/magnoliaAuthor/test.html : This is cause also by missing workspace in Link instance, then it doesn't remove ssite prefix from url because again no mapping matched in DomainNamePathTransformer#transform. SolutionWhen we creating the link from link pattern we should set the workspace to Link instance even when node wasn't resolved diff --git a/magnolia-core/src/main/java/info/magnolia/link/LinkUtil.java b/magnolia-core/src/main/java/info/magnolia/link/LinkUtil.java index c06d59bbbc..76173ebb47 100644 --- a/magnolia-core/src/main/java/info/magnolia/link/LinkUtil.java +++ b/magnolia-core/src/main/java/info/magnolia/link/LinkUtil.java @@ -548,10 +548,12 @@ public class LinkUtil { log.warn("Can't find node with uuid {} or handle {} in repository {}", uuid, fallbackHandle, defaultRepository); link = new Link(); link.setUUID(uuid); + link.setWorkspace(workspaceName); } catch (RepositoryException re) { log.warn("Can't find node with uuid {} or handle {} in repository {}", uuid, fallbackHandle, defaultRepository); link = new Link(); link.setUUID(uuid); + link.setWorkspace(workspaceName); } } link.setFallbackPath(fallbackHandle); This will fix both issues because site mapping will be correctly applied to linkStr and remove the handlePrefix from it. To be on safe side we can still check for site.getI18n() != null in CrossSiteAbsolutePathTransformer, but actually when i18n is not set it shouldn't get into this part of the code. |
| Comment by Pierre Sandrin [ 19/Sep/23 ] |
|
To whom it may help: We are using the URL-Translation Module and needed to update to 6.2.4 to fix this. |