Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-17998

Fix binary metadata writing escaping

    XMLWordPrintable

    Details

      Description

      Using a 7.4-SNAPSHOT from sept 24

      • Setup the following XML contribution using Studio:
       <extension target="org.nuxeo.binary.metadata"
                  point="metadataMappings">
         <!-- Define "processor" to use and specify the attached binary's xpath ("blobXPath") -->
         <!-- Technical "id" should be unique  -->
         <!-- "ignorePrefix" is by default set to true. Here metadata have prefixes, so set it to false. -->
         <metadataMapping id="Example" processor="exifTool" blobXPath="file:content" ignorePrefix="false">
           <!-- "name" = binary metadata  , "xpath" = document metadata -->
           <!-- See PDF metadata extraction example in this page -->
           <metadata name="PDF:Producer" xpath="dc:title"/>
           <metadata name="PDF:Author" xpath="dc:description"/>
         </metadataMapping>
      </extension>
      
      <!-- Define which mappings will be called by the listener, and under which conditions -->
      <extension target="org.nuxeo.binary.metadata"
                  point="metadataRules">
        <!-- "order" = priority , "async" = listener mode (set "true" to apply mapping as background work) -->
        <!-- Technical "id" should be unique  -->
        <rule id="default" order="0" enabled="true" async="false">
           <metadataMappings>
             <metadataMapping-id>Example</metadataMapping-id>
      
      
           </metadataMappings>
           <!-- see the link below for filter contributions -->
           <filters>
             <filter-id>hasFileType</filter-id>
      
           </filters>
         </rule>
       </extension>
       
       <extension target="org.nuxeo.ecm.platform.actions.ActionService"
                  point="filters">
         <filter id="hasFileType">
           <rule grant="true">
             <type>File</type>
           </rule>
         </filter>
       </extension>
      
      • Import a PDF file
      • Change its description to: Something else that "makes no sense" :'-)

      => An exception is thrown:

      14:41:24,708 ERROR [EventServiceImpl] Exception during binaryMetadataSyncListener sync listener execution, continuing to run other listeners
      java.lang.IllegalArgumentException: '-PDF:Producer=nuxeo_search_stats_demos -PDF:Author=Something\ else\ that\ "makes\ no\ sense"\ :-) ' contains illegal characters. It should match: [\p{L}_0-9-.%:=/\\ ]+
      	at org.nuxeo.ecm.platform.commandline.executor.service.CommandLineExecutorComponent.checkParameter(CommandLineExecutorComponent.java:214)
      	at org.nuxeo.ecm.platform.commandline.executor.service.executors.AbstractExecutor.replaceParams(AbstractExecutor.java:94)
      	at org.nuxeo.ecm.platform.commandline.executor.service.executors.AbstractExecutor.getParametersString(AbstractExecutor.java:65)
      	at org.nuxeo.ecm.platform.commandline.executor.service.executors.ShellExecutor.exec(ShellExecutor.java:59)
      	at org.nuxeo.ecm.platform.commandline.executor.service.CommandLineExecutorComponent.execCommand(CommandLineExecutorComponent.java:157)
      	at org.nuxeo.binary.metadata.internals.ExifToolProcessor.writeMetadata(ExifToolProcessor.java:94)
      	at org.nuxeo.binary.metadata.internals.BinaryMetadataServiceImpl.writeMetadata(BinaryMetadataServiceImpl.java:148)
      	at org.nuxeo.binary.metadata.internals.BinaryMetadataServiceImpl.handleUpdate(BinaryMetadataServiceImpl.java:251)
      	at org.nuxeo.binary.metadata.internals.BinaryMetadataServiceImpl.handleSyncUpdate(BinaryMetadataServiceImpl.java:227)
      	at org.nuxeo.binary.metadata.internals.listeners.BinaryMetadataSyncListener.handleEvent(BinaryMetadataSyncListener.java:57)
      

      => metadata sent to exiftool should be escaped properly to avoid such exceptions

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bchauvin Bertrand Chauvin
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: