Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3659

global <max-upload-size> is ignored

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 8.5.0
    • 8.0.5
    • Components
    • Security Level: Jean

    Description

      Steps to Reproduce

      configure a global max-upload-size in zk.xml

      	<system-config>
                    <max-upload-size>1024</max-upload-size><!-- 1MB -->
      	</system-config>
      

      create a default upload button in a zul file

      <button upload="true"/>
      

      Upload a file > 1MB

      Current Result

      upload succeeds

      Expected Result

      upload should fail based on configured size limit

      Root Cause

      side effect of ZK-3276

      https://github.com/zkoss/zk/commit/1ea21294b7c945b58d82736d1a95914231183b39#diff-85f1d140a009126e7598a79d9471887aR423

      A null value at component attribute level disables the default config.
      (and obsolete catch of NumberFormatException)

      Workaround

      1. specify upload limit at component level

      <button upload="true;maxsize=1024"/>
      

      2. globally set the maxsize custom-attribute in a lang-addon.zul

      <language-addon>
      	<addon-name>patchFileUploadLimit</addon-name>
      	<language-name>xul/html</language-name>
      	<depends>zul</depends>
      
      	<!-- patch ignored max size default config -->
      	<component>
      		<component-name>fileupload</component-name>
      		<extends>fileupload</extends>
      
      		<custom-attribute>
      			<attribute-name>org.zkoss.zk.upload.maxsize</attribute-name>
      			<attribute-value>${Integer.valueOf(1024)}</attribute-value>
      		</custom-attribute>
      	</component>
      </language-addon>
      

      place the file into your classpath in package metainfo/zk/lang-addon.xml
      see: https://www.zkoss.org/wiki/ZK_Client-side_Reference/Language_Definition

      Attachments

        Issue Links

          Activity

            People

              DevChu DevChu
              cor3000 cor3000
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 minutes
                  2m