Uploaded image for project: 'Lucee Development'
  1. LDEV-1393

toBinary() for Base64 encoded input streams throw error

    Details

    • Type: Bug
    • Status: Deployed
    • Priority: New
    • Resolution: Fixed
    • Affects Version/s: 5.1.4.19
    • Fix Version/s: 5.2.4.7
    • Labels:
      None
    • Environment:

      Redhat Enterprise 7 server, 4 CPU, 24GB RAM

    • Sprint:
      August 2017 Sprint

      Description

      An input stream (a Base64 encoded image stream) transfered in the FORM scope cannot longer be converted to binary.

      <!---
      Flex Snapshot kommt per form base64 kodiert an,
      wird umgewandelt in ein Bild
      und unter definierten Namen abgelegt.
      IR: 2008-04-10
      --->
      
      
      <cfparam name="form.imgBase64">
      <cfparam name="form.imgName">
      <cfparam name="snapshotFolder">
      
      
      
      <cfset imgsrc = toBinary(form.imgBase64)>
      <cftry>
      	<cffile file="#ExpandPath('.')#/#snapshotFolder#/#form.imgName#" action="write" output="#imgsrc#">
      <cfcatch>
      	<cfsavecontent variable="a">
      		<cfdump var="#cfcatch#">
      	</cfsavecontent>
      		<cffile action="write" file="#ExpandPath('.')#/catch.html" output="#a#">
      </cfcatch>
      </cftry>
      <cfabort>
      

      The error in the exception.log is :
      "ERROR","Thread-151","06/23/2017","16:28:25","",";Can't cast String [can't decode the the base64 input string [iVBORw0KGgoAAAANSUhEUgAABToAAAIbCAYAAADLgyHQAADOsE ... truncated], because the input string has an invalid length] to a value of type [binary]
      Java type of the object is java.lang.String;lucee.runtime.exp.CasterException: Can't cast String [can't decode the the base64 input string [iVBORw0KGgoAAAANSUhEUgAABToAAAIbCAYAAADLgyHQAADOsE ... truncated], because the input string has an invalid length] to a value of type [binary]
      at lucee.runtime.op.Caster.toBinary(Caster.java:2693)
      at lucee.runtime.functions.other.ToBinary.call(ToBinary.java:52)
      at lucee.runtime.functions.other.ToBinary.call(ToBinary.java:39)
      at program_helios368.hmonitor.flex._3prscoreboard.saveimg_cfm$cf.call(/program.helios/hmonitor/flex/3prscoreboard/saveImg.cfm:15)
      at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:928)
      at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:842)
      at lucee.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:63)
      at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
      at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2408)
      at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2398)
      at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2366)
      at lucee.runtime.engine.Request.run(Request.java:34)

        Attachments

          Activity

            People

            • Assignee:
              michaeloffner Michael Offner
              Reporter:
              adiedler@tecracer.de adiedler@tecracer.de
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: