えんどう やすゆき
yasuy****@javao*****
2005年 10月 25日 (火) 21:24:53 JST
えんどうです。 既出ならすみません。 http://www.kono.cis.iwate-u.ac.jp/~rwiki/index.rb?cmd=view;name=Hack 上記でも触れられていますが、 Gaucheのwww.cgiでIEからファイルアップロードすると、 パス区切り文字'\'が消えるようです。 ちょっと長いのですがKahuaで下記のようなプログラムを書いて、 IEから C:\Documents and Settings\yasuyuki\My Documents \My Pictures\old\ta....jpg といったファイルアップロードすると、 #?=("socket input" #<socket (closed)>):2:(cadr file) #?- "C:Documents and SettingsyasuyukiMy DocumentsMy Picturesoldta ... と表示されます。何らかのエスケープ処理が行われているのでしょうか? やろうとしていたのは (string-split (cadr file) "\ \") での ファイル名本体の取得です。 (define-entry (upload-file) (define (upload-file-form message type url) (or (and-let* ((user (karetta-current-user))) (standard-page (make <page> :title "Upload file" :key "/" :content `((form/cont (@ (enctype "multipart/form-data")) (@@ (cont ,check-upload-file)) , @ message (table (tr (td ,(if (equal? type "file") `(input (@ (type "radio") (name "type") (value "file") (checked "checked"))) `(input (@ (type "radio") (name "type") (value "file")))) "ファイル:") (td (input (@ (type "file") (name "file"))))) (tr (td ,(if (equal? type "url") `(input (@ (type "radio") (name "type") (value "url") (checked "checked"))) `(input (@ (type "radio") (name "type") (value "url")))) "外部URL:") (td (input (@ (type "text") (name "url") (size "30"))))) (tr (td) (td (input (@ (type "submit") (value "送信"))))) )))))) (please-login-page "/upload-file"))) (define check-upload-file (entry-lambda (:keyword type file url) (cond ((and (equal? type "file") (not file)) (upload-file-form '(p "ファイルを指定してください") type url)) ((and (equal? type "url") (string-null? url)) (upload-file-form '(p "外部URLを指定してください") type url)) ((equal? type "url") (upload-file-form `(p ,url) type url)) ((equal? type "file") (let* ( ;;(image-prop (make <image-porperty> ;; :owner (karetta-current-user) ;; :remote-host ;; (or (kahua-meta-ref "REMOTE_HOST") ;; (kahua-meta-ref "REMOTE_ADDR")))) (tmp-path #?=(car file)) (file-name #?=(cadr file)) (file-body #?=(let1 body #?=(string-split file-name "\\") (if (= (length body) 1) file-name (last body)))) (anc-name (call-with-input-process (string-append "echo " file-body "|kakasi -Ha -Ka -Ja -Ea -ka -C |sed 'y/: \^/__-/'") (lambda (p) (read-line p)))) ;;(file-ext (let1 body+ext (string-split file-name ".") ;; (if (= (length body+ext) 1) ;; "" (last body+ext)))) ) (upload-file-form `(p ,anc-name) type url))) ))) (upload-file-form '() "file" #f))