Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-2001

CSV-export: quotes in text fields has to be escaped

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.4.10
    • Fix Version/s: 10.5
    • Component/s: Course
    • Labels:
      None

      Description

      When grading students, a teacher can add a comment. If he uses quotes in the comment, the exported CSV format is being broken. (Double) quotes has to replaced by two (double) quotes (" -> "" or ' -> '').
      (https://de.wikipedia.org/wiki/CSV_%28Dateiformat%29)

      This patch fixes the problem:

      diff --git a/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java b/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java
      --- a/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java
      +++ b/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java
      @@ -300,8 +300,9 @@
       						if (comment != null) {
       							// put comment between double quote in order to prevent that
       							// '\t','\r' or '\n' destroy the excel table
      +							// A (double) quote must be represented by two (double) quotes.
       							tableContent.append("\"");
      -							tableContent.append(comment);
      +							tableContent.append(comment.replaceAll("\"", "\"\""));
       							tableContent.append("\"\t");
       						} else {
       							tableContent.append(mi);
      @@ -320,8 +321,9 @@
       						if (coachComment != null) {
       							// put coachComment between double quote in order to prevent that
       							// '\t','\r' or '\n' destroy the excel table
      +							// A (double) quote must be represented by two (double) quotes.
       							tableContent.append("\"");
      -							tableContent.append(coachComment);
      +							tableContent.append(coachComment.replaceAll("\"", "\"\""));
       							tableContent.append("\"\t");
       						} else {
       							tableContent.append(mi);
      

        Attachments

          Activity

            People

            Assignee:
            srosse Stéphane Rossé
            Reporter:
            stephan Stephan Clemenz
            Tester:
            Stephan Clemenz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m