[BusyBox 0001000]: this awk script don't work with busybox

bugs at busybox.net bugs at busybox.net
Sat Aug 26 14:10:59 UTC 2006


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=1000 
====================================================================== 
Reported By:                VEvgeniy
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   1000
Category:                   Standards Compliance
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             08-17-2006 08:28 PDT
Last Modified:              08-26-2006 07:10 PDT
====================================================================== 
Summary:                    this awk script don't work with busybox
Description: 
multipart.awk
------ start ------
BEGIN{
  RS="\015\012"
  getline
  FS="\015\012"
  RS=$0
  dirfile="/tmp"
}
{
  head=1
  getfile=""
  getname=""
  typedata="f"
  if($1=="--"){exit}
  if($1==""){$0=substr($0,3)}
  for(i=1;i<=NF;i++){
    head=head+length($i)+length(FS)
    if($i==""){
      value=$0
      value=substr(value,head,length(value)-head-1)
      if(getfile!=""){
        printf("%s",value) > dirfile"/"getfile
	value=getfile
      }
      for(nl=1;nl<=length(value);nl=nl+2){
        value=substr(value,1,nl-1)"\\"substr(value,nl)
      }
      while((nl=index(getname,"_"))>0){getname=substr(getname,1,nl-1)"
"substr(getname,nl+1)}
      if(value==""){value="''"}
      print getname" "value
      next
    }
    if(i==1){
      s=$1";"
      while(length(s)>0){
        n=index(s,";")
        sl=substr(s,1,n-1)
        while(substr(sl,1,1)==" "){sl=substr(sl,2)}
        if(typedata=="f"){
          if(sl=="Content-Disposition: form-data"){typedata="t"}
        }
        else{
          if(substr(sl,1,5)=="name="){
            getname=substr(sl,7,length(sl)-7)
          }
          if(substr(sl,1,9)=="filename="){
            getfile=substr(sl,11,length(sl)-11)
           
while((nl=index(getfile,"/"))>0){getfile=substr(getfile,nl+1)}
           
while((nl=index(getfile,"\\"))>0){getfile=substr(getfile,nl+1)}
          }
        }
        s=substr(s,n+1)
      }
    }
  }
}
------  end  ------
This awk script work with "multipart/form-data" enctype in cgi-script for
httpd
Only "multipart/form-data" enctype form download files to server.
If I use standart awk program, I have fine result with any files.
If I use busybox awk, I have bad result. My files cut.
problem strings:
...
      value=$0
      value=substr(value,head,length(value)-head-1)
      if(getfile!=""){
        printf("%s",value) > dirfile"/"getfile
	value=getfile
      }
...
more file - more probability problem
I have not fine result with 10MB file or more.
====================================================================== 

---------------------------------------------------------------------- 
 bernhardf - 08-25-06 08:40  
---------------------------------------------------------------------- 
I fear that i do not quite understand the problem you are describing.

Can you please attach a tarball with
1) the awk script
2) example input file
3) expected output file
4) a script that converts the input file to the outputfile?

regards, 

---------------------------------------------------------------------- 
 VEvgeniy - 08-26-06 07:10  
---------------------------------------------------------------------- 
my files size ~ 4.7 MB
bernhardf, please send your e-mail address

my e-mail vevgeniy82 at mail.ru 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
08-17-06 08:28  VEvgeniy       New Issue                                    
08-17-06 08:28  VEvgeniy       Status                   new => assigned     
08-17-06 08:28  VEvgeniy       Assigned To               => BusyBox         
08-25-06 08:40  bernhardf      Note Added: 0001588                          
08-26-06 07:10  VEvgeniy       Note Added: 0001593                          
======================================================================




More information about the busybox-cvs mailing list