local name="$1" count="${2:-1}"
local formdata state=begin
- while read -r formdata; do case "$formdata" in
+ while IFS='' read -r formdata; do case "$formdata" in
"--${multipart_boundary}--${CR}")
[ $state = data ] && return 0 \
|| return 1
[ $state = data ] && printf "%s\n" "$formdata"
;;
"${CR}")
- [ $state = dheader ] && state=data
+ if [ $state = dheader ]; then
+ sed -n "/--${multipart_boundary}\(--\)\?${CR}/q; p;" \
+ | head -c-2
+ return 0;
+ fi
[ $state = header ] && state=junk
;;
- *)
- [ $state = data ] && printf "%s\n" "$formdata"
- ;;
esac; done <"${multipart_cachefile}"
}
"${CR}")
[ $state = header ] && state=junk
;;
- *):
- ;;
esac; done <"${multipart_cachefile}"
filename="${formdata#*; filename=\"}"