[asterisk-bugs] [Asterisk 0015471]: cdr_custom produces incorrect csv format for clid

Asterisk Bug Tracker noreply at bugs.digium.com
Wed Jul 8 20:36:16 CDT 2009


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=15471 
====================================================================== 
Reported By:                dkerr
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   15471
Category:                   CDR/cdr_custom
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
Asterisk Version:           1.4.25.1 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2009-07-08 20:27 CDT
Last Modified:              2009-07-08 20:36 CDT
====================================================================== 
Summary:                    cdr_custom produces incorrect csv format for clid
Description: 
The csv file produced when cdr_custom is enabled is incorrect and cannot be
parsed by any csv parser (including excel, open office, php, perl, etc.
etc.. The problem occurs in the handling of caller ID strings.

Take this example template for cdr_custom.conf. 

[mappings]
Master.csv => "${CDR(clid)}","${CDR(src)}","${CDR(dst)}"

This specifies quoted CSV. The problem is that the format of a caller ID
is
'"lastname, firstname" <123456>'
Which contains quoted text.  The cdr_custom file produced would look like
this...

""lastname, firstname" <123456>","123456","100"

The correct format (which is produced by Asterisk default logging) is...

"""lastname, firstname"" <123456>","123456","100"

Note that quotes (") are translated into two consecutive quotes (""). 

====================================================================== 

---------------------------------------------------------------------- 
 (0107502) dkerr (reporter) - 2009-07-08 20:36
 https://issues.asterisk.org/view.php?id=15471#c107502 
---------------------------------------------------------------------- 
POTENTIAL WORK AROUND...

If the cdr_custom.conf file is changed from...

[mappings]
Master.csv => "${CDR(clid)}","${CDR(src)}","${CDR(dst)}", etc etc

to...

[mappings]
Master.csv => ${CDR(clid)},"${CDR(src)}","${CDR(dst)}", etc etc

Then most csv parsers will correctly handle the resulting cdr record.

Note the removal of the quotes around the caller ID variable. This causes
asterisk to log, for example...

"lastname, firstname" <123456>,"123456","100"

so the whole CDR string is not bounded by quotes, but the caller ID name
field is (which may legally contain a comma). Excel and other csv parsers
can handle this, while they cannot handle...

""lastname, firstname" <123456>","123456","100"

which is what asterisk produced today with the sample cdr_custom.conf
template.

David 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-07-08 20:36 dkerr          Note Added: 0107502                          
======================================================================




More information about the asterisk-bugs mailing list