Branch: Tag:

2010-03-30

2010-03-30 15:27:40 by Stephen R. van den Berg <srb@cuci.nl>

Added support for quoting suitable for generating CSV data.

Modified patch submitted by Stephen R. van den Berg <srb@cuci.nl>, thanks.
Fixes [bug 5376 (#5376)]: Add support for csv quoting.

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

1:   // This is a roxen pike module. Copyright © 1999 - 2009, Roxen IS.   // - // $Id: Roxen.pmod,v 1.288 2010/03/22 13:54:50 mast Exp $ + // $Id: Roxen.pmod,v 1.289 2010/03/30 15:27:40 grubba Exp $      #include <roxen.h>   #include <config.h>
2558:    case "oracle":    return replace (val, "'", "''");    +  case "csv": +  if (sizeof(val) && +  ((<' ', '\t'>)[val[0]] || (<' ', '\t'>)[val[-1]] || +  has_value(val, ",") || has_value(val, ";") || +  has_value(val, "\"") || has_value(val, "\n"))) { +  return "\"" + replace(val, "\"", "\"\"") + "\""; +  } +  return val; +     case "mysql-dtag":    // This is left for compatibility    return replace (val,
2654:   //! @value "wml"   //! HTML encoding, and doubling of any @tt{$@}'s.   //! + //! @value "csv" + //! CSV (Comma Separated Values) encoding. Properly quotes all + //! separator characters in CSV records (comma, semicolon, double-quotes + //! leading spaces and newlines). + //!   //! @value "pike"   //! Pike string quoting, for use in e.g. the @tt{<pike></pike>@}   //! tag. This means backslash escapes for chars that cannot occur