Wapp

Check-in [4cc53a980a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Adjust the regexp commands used to parse multipart/form-data to improved performance with very large upload files.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:4cc53a980a00b7ef64c2a6ed7f24f4c5ad8ef4d0a51396b0638d1b065b878fce
User & Date: drh 2018-02-06 16:54:53
Context
2018-02-06
17:58
Fix filename dequoting in multipart/form-data interpretation. Add two test files for multipart/form-data testing. check-in: 6cd6484c92 user: drh tags: trunk
16:54
Adjust the regexp commands used to parse multipart/form-data to improved performance with very large upload files. check-in: 4cc53a980a user: drh tags: trunk
16:36
Enhance the file upload test to show uploaded images inline. check-in: 089322b3a4 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to wapp.tcl.

534
535
536
537
538
539
540


541
542
543
544
545
546
547
548
549
    } elseif {[string match multipart/form-data* $ctype]} {
      regexp {^(.*?)\r\n(.*)$} [dict get $wapp CONTENT] all divider body
      set ndiv [string length $divider]
      while {[string length $body]} {
        set idx [string first $divider $body]
        set unit [string range $body 0 [expr {$idx-3}]]
        set body [string range $body [expr {$idx+$ndiv+2}] end]


        if {[regexp {^Content-Disposition: form-data; name="(.*)"; filename="(.*)"\r\nContent-Type: (.*)\r\n\r\n(.*)$}\
             $unit unit name filename mimetype content]} {
          dict set wapp $name.filename $filename
          dict set wapp $name.mimetype $mimetype
          dict set wapp $name.content $content
        }
      }
    }
  }







>
>
|
|







534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
    } elseif {[string match multipart/form-data* $ctype]} {
      regexp {^(.*?)\r\n(.*)$} [dict get $wapp CONTENT] all divider body
      set ndiv [string length $divider]
      while {[string length $body]} {
        set idx [string first $divider $body]
        set unit [string range $body 0 [expr {$idx-3}]]
        set body [string range $body [expr {$idx+$ndiv+2}] end]
        if {[regexp {^Content-Disposition: form-data; (.*?)\r\n\r\n(.*)$} \
             $unit unit hdr content] &&
            [regexp {name="(.*)"; filename="(.*)"\r\nContent-Type: (.*?)$}\
              $hdr hr name filename mimetype]} {
          dict set wapp $name.filename $filename
          dict set wapp $name.mimetype $mimetype
          dict set wapp $name.content $content
        }
      }
    }
  }