]> git.plutz.net Git - shellwiki/commitdiff
Bugfix: file uploads got NULL characters converted to Linefeeds when using busybox sed
authorPaul Hänsch <paul@plutz.net>
Mon, 12 Jun 2023 11:38:47 +0000 (13:38 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 12 Jun 2023 11:38:47 +0000 (13:38 +0200)
multipart.sh

index 09e3ca8f256fd1bd598c9175150eb74aa78e7762..7c0d5dd2da631cf9babe05726f678087c9c389c5 100755 (executable)
@@ -53,8 +53,9 @@ multipart(){
       ;;
     "${CR}")
       if [ $state = dheader ]; then
-        sed -n "/--${multipart_boundary}\(--\)\?${CR}/q; p;" \
-        | head -c-2
+        # Do not use `sed -n` (or busybox sed will "convert" NULL to LF)
+        sed "/--${multipart_boundary}\(--\)\?${CR}/{x;q;}" \
+        | head -c-3
         return 0;
       fi
       [ $state = header ] && state=junk