Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-8931

rendering of RichTextField data fails if it contains a link which doesn't exist

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: High High
    • 6.3.0, 6.2.35
    • None
    • None
    • None

      When editor use CKeditor (richtextfield) and use build-in functionality for internal link - a.k.a. paragraph in richtextfield contains link to another internal page. 

      e.g content of the richtextfield (content.desc):

      <p>Some text with link <a href="${link:{uuid:{d17e1eba-ea6c-4b65-afd5-43fb28633eb5},repository:{website},path:{/international-programmes}}}">International Busines offering</a></p>

      But if this page doest exists:

      1. was deleted
      2. is not published
      3. another editor doesn't have the right to see such page.

      Then rendering this data in template using

       

      ${cmsfn.decode(content).desc) 

      Fails!

       

      this is possible partially workaround by 

       

      [#attempt]
          ${cmsfn.decode(content).desc}
      [#recover]
          // print something else
      [/#attempt] 

      But this is still not ideal, because it will not render whole paragraph (whole content of richtextfiled)

      Expected: Paragraph will be rendered and only link would not have a link <a href>

       

      But there is second part in case we need to check if content exist first, code like this:

       

      [#if content.title?has_content || content.desc?has_content]
      
          <section class="ArticleSection">
              [#if content.title?has_content]
                  <h2 class="ArticleSection--title">${content.title!}</h2>
              [/#if]
      
              [#attempt]
                  <div class="richtext">
                      [#if content.desc?has_content]
                          ${cmsfn.decode(content).desc}
                      [/#if]
                  </div>
              [#recover]             
                  // print something else         
              [/#attempt]
          </section>
      [/#if] 

      This will already fail on line #1 :

       

       

      Error while rendering [/...] with template [...:components/basicContent2] for URI [/...]: RenderException: freemarker.core._MiscTemplateException: Expression has thrown an unchecked exception; see the cause exception. The blamed expression: ==> content.desc [in template ".../templates/components/basicContent.ftl" at line 37, column 35] ---- FTL stack trace ("~" means nesting-related): - Failed at: #if content.title?has_content || cont... [in template ".../templates/components/basicContent.ftl" at line 37, column 1] ---- info.magnolia.rendering.engine.RenderException: freemarker.core._MiscTemplateException: Expression has thrown an unchecked exception; see the cause exception. The blamed expression: ==> content.desc [in template "..../templates/components/basicContent.ftl" at line 37, column 35] 

      Expected: content.desc?has_content will return true or fals no matter if it contains link which doesn't exists or not.

      Thank you

      Developer notes:

      see attached stack-trace.txt:

      Caused by: java.lang.NullPointerException
              at info.magnolia.multisite.CrossSiteAbsolutePathTransformer.prefixLink(CrossSiteAbsolutePathTransformer.java:67) ~[magnolia-module-multisite-2.1.2.jar:?] 

        Acceptance criteria

              mdivilek Milan Divilek
              tgregovsky Tomáš Gregovský
              DeveloperX
              Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved:
                Work Started:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - Not Specified
                    Not Specified
                    Logged:
                    Time Spent - 2.5h
                    2.5h