Branch: Tag:

2004-01-27

2004-01-27 13:30:27 by Jonas Wallden <jonasw@roxen.com>

Detect double escaping in the magic charset variable. This can happen on
some browsers (e.g. Safari 1.0) when Java applets request pages.

Rev: server/etc/modules/Roxen.pmod:1.168

1:   // This is a roxen pike module. Copyright © 1999 - 2001, Roxen IS.   // - // $Id: Roxen.pmod,v 1.167 2003/12/08 14:02:54 noring Exp $ + // $Id: Roxen.pmod,v 1.168 2004/01/27 13:30:27 jonasw Exp $      #include <roxen.h>   #include <config.h>
2196:    //! encoding of the string "åäö&#x829f;".    //! See the roxen-automatic-charset-variable tag.   { +  // If the first character is "%" the whole request is most likely double +  // encoded. We'll undo the decoding by combining the charset decoder with +  // http_decode_string(). +  if (has_prefix(åäö, "%") && !has_prefix(åäö, "%%")) { +  report_notice("Warning: Double HTTP encoding detected: %s\n", åäö); +  function decoder = get_client_charset_decoder(http_decode_string(åäö), id); +  if (decoder) { +  return lambda(string s) { return decoder(http_decode_string(s)); }; +  } else { +  return http_decode_string; +  } +  } +     // Netscape seems to send "?" for characters that can't be represented    // by the current character set while IE encodes those characters    // as entities, while Opera uses "\201" or "?x829f;"...
2203:    ({ "&aring;", "&#229;", "&#xe5;",    "&auml;", "&#228;", "&#xe4;",    "&ouml;", "&#246;", "&#xf6;", -  "&#33439;","&#x829f;", "\201", "?x829f;" }), +  "&#33439;","&#x829f;", "\201", "?x829f;", +  "\x829f" }),    ({ "?", "?", "?",    "?", "?", "?",    "?", "?", "?", -  "?", "?", "?", "?" })); +  "?", "?", "?", "?", +  "?" }));       switch( test ) {    case "edv":