Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-158827

Image Field attributes having character / receives character \ before them

Details

    Description

      Steps to reproduce

      • Go to Content & Data > Web Content
      • Click on Structures tab
      • Add a new Structure with a Image field
      • Click on Advanced tab and copy the Field Reference
      • Save
      • Click on Web Content tab
      • Add a Web Content using the created Structure. Make sure to input Hyperloop is intented to reach 1200 km/h speed, without difficulty in the image description field.
      • Go to Design > Templates
      • Click on Widget Templates
      • Add an Asset Publisher Template with the following code:
      <#if entries?has_content>
      	<#list entries as entry>
      		<#assign docXml =  saxReaderUtil.read(entry.getAssetRenderer().getArticle().getContentByLocale(locale)) >		<#assign ArtImage = docXml.valueOf("//dynamic-element[@name='fieldReferenceOfImageField']/dynamic-content/text()") />		<#if ArtImage?has_content>
      				<#assign ArtImageDiv = ArtImage?eval />
      		</#if>
      	</#list>
      </#if>
      

      Note: replace the name fieldReferenceOfImageField by the Field Reference copied by you previously

      • Go to Site Builder > Pages and create a new page of type Widget Page
      • Go to the created Widget Page and drag and drop an Asset Publisher
      • Go to the Asset Publisher Configuration and choose Dynamic in the Asset Selection section
      • Click on the Display Settings
      • Select the created Template as the Display Template
      • Save and check how the Asset Publisher displays the Web Content

       

      Actual result

      The Web Content isn't displayed and the following error is shown instead:

      Failed to "?eval" string with this error:
      
      ---begin-message---
      Syntax error in ?eval-ed string in line 1, column 49:
      Lexical error: encountered "/" (47), after "\"Hyperloop is intented to reach 1200 km\\".
      ---end-message---
      
      The failing expression:
      ==> ArtImage?eval  [in template "20097#20123#41371" at line 8, column 56]
      
      ----
      FTL stack trace ("~" means nesting-related):
      	- Failed at: #assign ArtImageDiv = ArtImage?eval  [in template "20097#20123#41371" at line 8, column 33]
      ----
      
      	
      		
      
      
      
      				1<#if entries?has_content> 
      
      
      				2	<#list entries as entry> 
      
      
      				3		<#assign docXml =  saxReaderUtil.read(entry.getAssetRenderer().getArticle().getContentByLocale(locale)) > 
      
      
      				4 
      
      
      				5		<#assign ArtImage = docXml.valueOf("//dynamic-element[@name='Image21837887']/dynamic-content/text()") /> 
      
      
      				6 
      
      
      				7		<#if ArtImage?has_content> 
      
      
      				8				<#assign ArtImageDiv = ArtImage?eval /> 
      
      
      				9		</#if> 
      
      
      				10	</#list> 
      
      
      				11</#if

       

      New error (09th August 2022):

      An error occurred while processing the template.
      The following has evaluated to null or missing:
      ==> entry.getAssetRenderer().getArticle  [in template "20097#20123#43474" at line 3, column 55]
      
      ----
      Tip: It's the step after the last dot that caused this error, not those before it.
      ----
      Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
      ----
      
      ----
      FTL stack trace ("~" means nesting-related):
      	- Failed at: #assign docXml = saxReaderUtil.read(e...  [in template "20097#20123#43474" at line 3, column 17]
      ----
      1<#if entries?has_content> 
      2	<#list entries as entry> 
      3		<#assign docXml =  saxReaderUtil.read(entry.getAssetRenderer().getArticle().getContentByLocale(locale)) >		<#assign ArtImage = docXml.valueOf("//dynamic-element[@name='image']/dynamic-content/text()") />		<#if ArtImage?has_content> 
      4				<#assign ArtImageDiv = ArtImage?eval /> 
      5		</#if> 
      6	</#list> 
      7</#if> 

       

      Expected result

      The Web Content should be displayed without errors

      Attachments

        Activity

          People

            rafaella.jordao Rafaella Jordao
            renato.rego Renato Rêgo
            Rafaella Jordao Rafaella Jordao
            Carolina Barbosa Carolina Barbosa
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              3 days ago

              Packages

                Version Package
                7.4.3.42 CE GA42
                Master