Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-27688

tinyMCE relative URLs set to true create incorrect URL

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a bug
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: HTML Editor (TinyMCE)
    • Labels:
    • Environment:
      Windows 2008 R2 Sp1; PHP 5.3.5, tinyMCE 3.3.9.2;
    • Testing Instructions:
      Hide

      1. Create some URLs in a course topic using asolute src URL for images
      2. change LIB.php to use relative URLs
      3. Edit the topic html TWICE to see changes each time
      4. set 'remove_script_host' => true to see if tinyMCE removes the host part of the name but not the full Moodle prefix defined in wwwroot or the document_base_url

      Show
      1. Create some URLs in a course topic using asolute src URL for images 2. change LIB.php to use relative URLs 3. Edit the topic html TWICE to see changes each time 4. set 'remove_script_host' => true to see if tinyMCE removes the host part of the name but not the full Moodle prefix defined in wwwroot or the document_base_url
    • Workaround:
      Hide

      If you change the relative HTML in tinyMCE to include the missing slash at the front, it then changes that to '../' next time you edit the html. While this works fine for the course view of the topic, it does not view the images whilst in the editor.

      Show
      If you change the relative HTML in tinyMCE to include the missing slash at the front, it then changes that to '../' next time you edit the html. While this works fine for the course view of the topic, it does not view the images whilst in the editor.
    • Affected Branches:
      MOODLE_20_STABLE

      Description

      Our development server is different to production server and backup/restore of courses to migrate from dev to prod does not fix absolute URLs. Relative URLs are required to migrate courses between servers.

      When tinyMCE has the relative_url param set to true; the relative URLs in the editor are incorrect.
      the paramater 'document_base_url' is set incorrectly according to tinyMCE doc http://tinymce.moxiecode.com/wiki.php/Configuration:document_base_url

      in \moodle\lib\editor\tinymce\lib.php

       'document_base_url' => $CFG->httpswwwroot,

      should be

       'document_base_url' => $CFG->httpswwwroot .'/',

      This corrects the issue with making absolute URLs relative in the course topic editor but then they are incorrect when displayed in course view.

      config.php: $CFG->wwwroot   = 'http://moodle.xxx.com.au/moodle';

      HTML that was absolute is will be incorrectly changed to relative

      src="http://moodle.xxx.com.au/moodle/local/pix/lesson.png"

      becomes

      src="local/pix/lesson.png"

      which displays incorrectly in course view as "http://moodle.xxx.com.au/moodle/course/local/pix/lesson.png"

      relative URL should be src="/local/pix/lesson.png" to dislay correctly in course view as "http://moodle.xxx.com.au/moodle/local/pix/lesson.png"

      The problem is how the delimiting slash on the wwwroot is handled by Moodle and tinyMCE, one requires it and one does not.

      If the relative URL tinyMCE created had a leading slash (since $CFG->wwwroot does not have a trailing slash) I think this would work fine.

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            mark.emery Mark Emery
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: