Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4785d221

Von Sven Schöling vor mehr als 12 Jahren hinzugefügt

  • ID 4785d221f80066b7f85ffde083085ed2d648a181
  • Vorgänger 1954092b
  • Nachfolger 854a9820

Duplizierung der Datenstruktur bei multiencoding POST submits

Unterschiede anzeigen:

SL/Request.pm
51 51

  
52 52
sub _parse_multipart_formdata {
53 53
  my ($target, $temp_target, $input) = @_;
54
  my ($name, $filename, $headers_done, $content_type, $boundary_found, $need_cr, $previous, $encoding, $transfer_encoding);
54
  my ($name, $filename, $headers_done, $content_type, $boundary_found, $need_cr, $previous, $p_attachment, $encoding, $transfer_encoding);
55 55

  
56 56
  # We SHOULD honor encodings and transfer-encodings here, but as hard as I
57 57
  # looked I couldn't find a reasonably recent webbrowser that makes use of
......
103 103
          substr $line, $-[0], $+[0] - $-[0], "";
104 104
        }
105 105

  
106
        $previous                = _store_value(defined $filename ? $target : $temp_target, $name, '') if ($name);
107
        $temp_target->{FILENAME} = $filename if (defined $filename);
106
        if ($name) {
107
          # legacy, some old upload routines expect this to be here
108
          $temp_target->{FILENAME} = $filename if defined $filename;
108 109

  
109
        # for multiple uploads: save the attachments in a SL/Mailer like structure
110
        if ($name && defined $filename) {
111
          _store_value($target, "ATTACHMENTS.$name.data", $previous);
112
          _store_value($temp_target, "ATTACHMENTS.$name.filename", $filename);
110
          # name can potentially be both a normal variable or a file upload
111
          # a file upload can be identified by its "filename" attribute
112
          # the thing is, if a [+] clause vivifies atructur in one of the
113
          # branches it must be done in both, or subsequent "[]" will fail
114
          my $temp_target_slot = _store_value($temp_target, $name);
115
          my $target_slot      = _store_value($target,      $name);
116

  
117
          # set the reference for appending of multiline data to the correct one
118
          $previous            = defined $filename ? $target_slot : $temp_target_slot;
119

  
120
          # for multiple uploads: save the attachments in a SL/Mailer like structure
121
          if (defined $filename) {
122
            my $target_attachment      = _store_value($target,      "ATTACHMENTS.$name", {});
123
            my $temp_target_attachment = _store_value($temp_target, "ATTACHMENTS.$name", {});
124

  
125
            $$target_attachment->{data}          = $previous;
126
            $$temp_target_attachment->{filename} = $filename;
127

  
128
            $p_attachment = $$temp_target_attachment;
129
          }
113 130
        }
114 131

  
115 132
        next;
......
117 134

  
118 135
      if ($line =~ m|^content-type\s*:\s*(.*?)[;\$]|i) {
119 136
        $content_type = $1;
120
        _store_value($temp_target, "ATTACHMENTS.$name.content_type", $1);
137
        $p_attachment->{content_type} = $1;
121 138

  
122 139
        if ($content_type =~ /^text/ && $line =~ m|;\s*charset\s*:\s*("?)(.*?)\1$|i) {
123 140
          $encoding = $2;
......
131 148
        if ($transfer_encoding  && $transfer_encoding !~ /^[78]bit|binary$/) {
132 149
          die 'Transfer encodings beyond 7bit/8bit and binary are not implemented.';
133 150
        }
151
        $p_attachment->{transfer_encoding} = $transfer_encoding;
134 152

  
135 153
        next;
136 154
      }
......
158 176
        # Workaround for a bug: converting $from->{$key} directly
159 177
        # leads to 'undef'. I don't know why. Converting a copy works,
160 178
        # though.
161
        $to->{$key} = $iconv->convert("" . $from->{$key});
179
        $to->{$key} = $iconv->convert("" . $from->{$key}) if defined $from->{$key} && !defined $to->{$key};
162 180
      } else {
163 181
        $to->{$key} ||= {} if 'HASH'  eq ref $from->{$key};
164 182
        $to->{$key} ||= [] if 'ARRAY' eq ref $from->{$key};

Auch abrufbar als: Unified diff