Moodle
  1. Moodle
  2. MDL-38426

Handle plain text content type for a drag and drop event in mod/label

    Details

    • Testing Instructions:
      Hide
      1. Turn on dnd upload of text (in experimental settings)
      2. Drag some plain text onto a course (Gedit works under Linux, maybe Notepad under Windows?)
      3. Create a label
        1. Check that the line breaks are retained
      4. Drag some HTML text (out of another window of the same browser)
      5. Create another label
        1. Check that the HTML formatting is retained

      As always with drag and drop - Firefox, Chrome, Safari, IE10

      Show
      Turn on dnd upload of text (in experimental settings) Drag some plain text onto a course (Gedit works under Linux, maybe Notepad under Windows?) Create a label Check that the line breaks are retained Drag some HTML text (out of another window of the same browser) Create another label Check that the HTML formatting is retained As always with drag and drop - Firefox, Chrome, Safari, IE10
    • Affected Branches:
      MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      MDL-38426_dnd_plain_text
    • Rank:
      48358

      Description

      Dropping plain text with line breaks isn't handled correctly by mod/label: the line breaks disappear. Davo suggests that the fix is:

      "The correct fix is going to be similar to the code in mod/page/lib.php, page_dndupload_handle:

      if ($uploadinfo->type == 'text/html') {
          $data->contentformat = FORMAT_HTML; $data->content = clean_param($uploadinfo->content, PARAM_CLEANHTML);
      } 
      else {
          $data->contentformat = FORMAT_PLAIN; $data->content = clean_param($uploadinfo->content, PARAM_TEXT);
      }
      

      "

        Activity

        Hide
        Michael de Raadt added a comment -

        Thanks for reporting that, Petruk, and thanks for taking this on, Davo.

        Show
        Michael de Raadt added a comment - Thanks for reporting that, Petruk, and thanks for taking this on, Davo.
        Hide
        Davo Smith added a comment -

        Small fix, so skipping peer review

        Show
        Davo Smith added a comment - Small fix, so skipping peer review
        Hide
        Eloy Lafuente (stronk7) added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        Aparup Banerjee added a comment -

        looks good.

        Show
        Aparup Banerjee added a comment - looks good.
        Hide
        Damyon Wiese added a comment -

        Hi Davo

        Why isn't mod_label cleaning the content like in patch suggested in the description?

        It looks like it should be from the comment in "course/dndupload.php" -

        It will be up to each plugin to clean this data, before saving it.

        Show
        Damyon Wiese added a comment - Hi Davo Why isn't mod_label cleaning the content like in patch suggested in the description? It looks like it should be from the comment in "course/dndupload.php" - It will be up to each plugin to clean this data, before saving it .
        Hide
        Damyon Wiese added a comment -

        I confirmed the lack of cleaning is a bug and added an issue for it (security).

        Show
        Damyon Wiese added a comment - I confirmed the lack of cleaning is a bug and added an issue for it (security).
        Hide
        Damyon Wiese added a comment -

        This issue is fine and has been integrated.

        Thanks Davo!

        Show
        Damyon Wiese added a comment - This issue is fine and has been integrated. Thanks Davo!
        Hide
        Frédéric Massart added a comment -

        Test passed on Firefox and Chrome. However the HTML drag & drop can easily cause the page layout to be altered. I don't know if it's a known issue, but I dragged an activity name and action icons to the same section, and all the HTML went broken.

        Show
        Frédéric Massart added a comment - Test passed on Firefox and Chrome. However the HTML drag & drop can easily cause the page layout to be altered. I don't know if it's a known issue, but I dragged an activity name and action icons to the same section, and all the HTML went broken.
        Hide
        Damyon Wiese added a comment -

        This issue has been integrated upstream and is now available via git (and in some hours, via mirrors and downloads).

        Thanks for your contributions!

        Show
        Damyon Wiese added a comment - This issue has been integrated upstream and is now available via git (and in some hours, via mirrors and downloads). Thanks for your contributions!

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: