Closed Bug 394634 Opened 17 years ago Closed 16 years ago

Double Quotes in Description not handled correctly when exported to .CSV files

Categories

(Calendar :: Import and Export, defect)

defect
Not set
minor

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: eznie0ba, Assigned: Hb)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4pre) Gecko/20070614 Sunbird/0.5

I was trying to export one calendar that I have used for a while now. In several of the events within this calendar, I used double quotes (") to surround some text in the comments.

Upon exporting the calendar to a .csv file, I noticed these double quotes are escaped properly for the opening quote (""), but the closing quote is not escaped, left as a single quote (").



Reproducible: Always

Steps to Reproduce:
1. Open calendar and create an event.
2. Include a "quoted string" in the description for the event.
3. Export the calendar.
Actual Results:  
The resulting value for the Description column will look something like:

....,"Include a ""quoted string" in the description for the event", ...

Expected Results:  
The resulting value for the Description column should look something like:

....,"Include a ""quoted string"" in the description for the event", ...

By not properly escaping the closing quote, import into Excel, OpenOffice, and possibly other products fails.
Version: unspecified → Sunbird 0.5
Is this as simple as making the string replace() call to a global search and replace in the file "C:\Program Files\Mozilla Sunbird\js\calOutlookCSVImportExport.js", function csv_exportToStream(), line 441-444?

        line = line.map(function(v) {
            v = String(v).replace(/"/g,'""');
            return '"'+v+'"';
        })

By adding the 'g' (global) flag to the regex, it appears to escape quoted text properly.
Depends on: 359083
Based on eznie0ba suggestion now replacing all occurrences of douple quotes
Assignee: nobody → hb
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #304862 - Flags: review?(mvl)
Comment on attachment 304862 [details] [diff] [review]
Patch for global substitution in regex

r=mvl
Attachment #304862 - Flags: review?(mvl) → review+
No longer depends on: 359083
Flags: wanted-calendar0.8?
Keywords: checkin-needed
OS: Windows XP → All
Hardware: PC → All
Version: Sunbird 0.5 → unspecified
Fix checked into trunk and MOZILLA_1_8_BRANCH.
Severity: normal → minor
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Flags: wanted-calendar0.8?
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 0.8
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.