Overview
Comment: | Added recovery from bad form. but it is broken and I don't know why. Still seems rare ... |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
44c407806c81f9be9a0460749d548944 |
User & Date: | matt on 2016-09-24 07:07:37 |
Other Links: | manifest | tags |
Context
2016-09-25
| ||
17:10 | Added conversion to s:session-var-get. WARNING: Need to use 'raw in many cases check-in: 445ea184ae user: matt tags: trunk | |
2016-09-24
| ||
07:07 | Added recovery from bad form. but it is broken and I don't know why. Still seems rare ... check-in: 44c407806c user: matt tags: trunk | |
2016-09-22
| ||
06:28 | Added safe handling for params check-in: 4bccacb50f user: matt tags: trunk | |
Changes
Modified formdat.scm from [5b06a4d3e0] to [9664a46ced].
︙ | ︙ | |||
105 106 107 108 109 110 111 | (let* ((datstr (open-input-string dat)) (result (read-string (caar index) datstr)) (remdat (read-string #f datstr))) (close-input-port datstr) (list result remdat))))) ;; inp is port to read data from, maxsize is max data allowed to read (total) | | > > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | (let* ((datstr (open-input-string dat)) (result (read-string (caar index) datstr)) (remdat (read-string #f datstr))) (close-input-port datstr) (list result remdat))))) ;; inp is port to read data from, maxsize is max data allowed to read (total) (define (formdat:dat->list inp maxsize #!key (debug-port #f)) ;; read 1Meg chunks from the input port. If a block is not complete ;; tack on the next 1Meg chunk as needed. Set up so the header is always ;; at the beginning of the chunk ;;-----------------------------29932024411502323332136214973 ;;Content-Disposition: form-data; name="input-picture"; filename="breadfruit.jpg" ;;Content-Type: image/jpeg (let loop ((dat (read-string 1000000 inp)) (res '()) (siz 0)) (if debug-port (format debug-port "dat: ~A\n" dat)) (if debug-port (format debug-port "eof: ~A\n" (eof-object? (read inp)))) (if (> siz maxsize) (begin (print "DATA TOO BIG") res) (let* ((datstr (open-input-string dat)) (header (formdat:read-header datstr)) (key (if (not (null? header))(car header) #f)) |
︙ | ︙ | |||
160 161 162 163 164 165 166 | (let ((request-method (get-environment-variable "REQUEST_METHOD"))) (if (and request-method (string=? request-method "POST")) (formdat:load-all-port (current-input-port))))) ;; (s:process-cgi-input (caaar dat)) (define (formdat:load-all-port inp) | | > | | | | > | > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | (let ((request-method (get-environment-variable "REQUEST_METHOD"))) (if (and request-method (string=? request-method "POST")) (formdat:load-all-port (current-input-port))))) ;; (s:process-cgi-input (caaar dat)) (define (formdat:load-all-port inp) (let* ((formdat (make-formdat:formdat)) (debugp #f)) ;; (open-output-file (conc "/tmp/delme-" (current-user-id) ".log")))) ;; (write-string (read-string #f inp) #f debugp) ;; destroys all data! (formdat:initialize formdat) (let ((alldats (formdat:dat->list inp 10e6 debug-port: debugp))) (if debugp (format debugp "formdat : alldats: ~A\n" alldats)) (let ((firstitem (car alldats)) (multipass #f)) (if (and (not (null? firstitem)) (not (null? (car firstitem)))) (if (string-match formdat:delim-patt-rex (caar firstitem)) (set! multipass #t))) (if multipass ;; handle multi-part form (for-each (lambda (datlst) (let* ((header (formdat:extract-header-info (car datlst))) (name (if (assoc 'name header) |
︙ | ︙ | |||
199 200 201 202 203 204 205 | alldats) ;; handle single part form ;; (if (and (string? name) ;; (string=? name "")) ;; this is the short form input I guess ;; (let* ((datstr (caar datlst)) ;; (munged (s:process-cgi-input datstr))) ;; (print "datstr: " datstr " munged: " munged) | > > > | | | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | alldats) ;; handle single part form ;; (if (and (string? name) ;; (string=? name "")) ;; this is the short form input I guess ;; (let* ((datstr (caar datlst)) ;; (munged (s:process-cgi-input datstr))) ;; (print "datstr: " datstr " munged: " munged) (if (and (not (null? alldats)) (not (null? (car alldats))) (not (null? (caar alldats)))) (formdat:load formdat (s:process-cgi-input (caaar alldats))))) ;; munged)) ;; (format debugp "formdat : name: ~A content: ~A\n" name content) (if debugp (close-output-port debugp)) formdat)))) #| (define inp (open-input-file "tests/example.post.in")) (define dat (read-string #f inp)) (define datstr (open-input-string dat)) |
︙ | ︙ |
Modified html-filter.scm from [14891b2741] to [7dc1b6a3b0].
︙ | ︙ | |||
177 178 179 180 181 182 183 184 185 186 187 188 189 190 | (string-append result chstr rem) (string-append result head)))) ;; (print "head: " head " num: " num " ch: |" ch "| chstr: " chstr) (if (null? tail) newres (loop (car tail)(cdr tail) newres)))))))) (define (s:process-cgi-input instr) (map (lambda (xy) (list (string->symbol (s:decode-str (car xy))) (if (eq? (length xy) 1) "" (s:decode-str (cadr xy))))) (s:divy-up-cgi-str instr))) | > > > > > | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | (string-append result chstr rem) (string-append result head)))) ;; (print "head: " head " num: " num " ch: |" ch "| chstr: " chstr) (if (null? tail) newres (loop (car tail)(cdr tail) newres)))))))) ;; probably a bug: ;; ;; (s:process-cgi-input "=bar") ;; => ((bar "")) ;; (define (s:process-cgi-input instr) (map (lambda (xy) (list (string->symbol (s:decode-str (car xy))) (if (eq? (length xy) 1) "" (s:decode-str (cadr xy))))) (s:divy-up-cgi-str instr))) |
︙ | ︙ |
Modified setup.scm from [c2c51e03a9] to [77c57eae95].
︙ | ︙ | |||
77 78 79 80 81 82 83 84 85 86 87 88 89 90 | (define (s:session-var-get-n-del! key) (let ((val (session:page-get s:session key))) (session:del! s:session "*sessionvars*" key) val)) (define (s:session-var-del! key) (session:del! s:session "*sessionvars*" key)) ;; utility to get all vars as hash table (define (s:session-get-sessionvars) (sdat-get-sessionvars s:session)) ;; inputs ;; | > > | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | (define (s:session-var-get-n-del! key) (let ((val (session:page-get s:session key))) (session:del! s:session "*sessionvars*" key) val)) (define (s:session-var-del! key) (session:del! s:session "*sessionvars*" key)) (define s:session-var-delete! s:session-var-del!) ;; utility to get all vars as hash table (define (s:session-get-sessionvars) (sdat-get-sessionvars s:session)) ;; inputs ;; |
︙ | ︙ |