[Clipart] upload script problem?

Jonadab the Unsightly One jonadab at bright.net
Mon Mar 28 19:50:11 PST 2005

"Stephen Silver" <ocalocal at btinternet.com> writes:

>> 2.  The upload script attempted to place the submitted file
>>      into the value attribute of the (hidden) userfile input;
>>      however, this appears not to work for binary files, for
>>      reasons that are not clear to me.
> This is the problem.  It would also be a problem some text files.
> The file is treated as being Windows codepage 1252 (that is,
> Latin-1, but with Microsoft-specific stuff in the unused region
> 80-9F) and is encoded mainly as HTML entities and character
> references.  But the page is UTF-8, so when these things are
> converted back to bytes, you get something completely different than
> you started with.

The POD for HTML::Entities *claims* that the encode_entities function,
the way I am using it without a second argument, encodes "control
chars, high-bit chars, and the <, &, >, and " characters."  I would
*think* that would be everything except printable ASCII characters,
but maybe I am missing something.  Here is the way I am calling it,

  if ($value{userfile}) {
    $userfile = '<input name="userfile" type="hidden" value="'
      .(encode_entities($value{userfile})).'" />
      <!-- *** *************** (end of userfile input) *************** *** -->
      <input type="hidden" name="filename" value="'.$value{filename}.'" />';
  } else {
    $userfile = '<input name="userfile" type="file" size="40" />';

I tested with encode_entities_numeric (because, trying that was easy),
but it does not seem to solve the problem.  This bug may have to wait
for the charset issues to be sorted out in general.  Unless there's a
way I can instruct the browser not to modify or re-encode the thing,
or unless we decide to store the file on the server ad interim and
send the browser a cookie that refers to it, which would also save
bandwidth but create other issues.  But it seems to me the best
solution would be to figure out the whole character set thing, which
we need to do anyway.

split//,"ten.thgirb\@badanoj$/ --";$\=$ ;-> ();print$/

More information about the clipart mailing list