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

URL resource trim problem

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5, 2.6
    • Fix Version/s: 2.5.3
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide

      Create/edit URL resource and try to enter URLs that are valid or not valid, with or without extra spaces in the beginning/end.
      Try to leave field empty or containing just spaces.

      Make sure that empty (or ' ') URL is not accepted, extra spaces are trimmed.

      Please note that URL validation is very light here.

      Show
      Create/edit URL resource and try to enter URLs that are valid or not valid, with or without extra spaces in the beginning/end. Try to leave field empty or containing just spaces. Make sure that empty (or ' ') URL is not accepted, extra spaces are trimmed. Please note that URL validation is very light here.
    • Workaround:
      Hide

      The cause of the problem seems to be, that in mod_url_mod_form (/mod/url/mod_form.php line 54) the 'externalurl' field type is PARAM_URL and when inserting URL with space in end, then it will not be valid URL and the value gets empty.

      When changing the described line as the following:

      -        $mform->setType('externalurl', PARAM_URL);
      +        $mform->setType('externalurl', PARAM_TEXT);
      

      then the form starts to work as expected.
      The URL gets validated anyway in function "validation" in the same file.

      Show
      The cause of the problem seems to be, that in mod_url_mod_form (/mod/url/mod_form.php line 54) the 'externalurl' field type is PARAM_URL and when inserting URL with space in end, then it will not be valid URL and the value gets empty. When changing the described line as the following: - $mform->setType('externalurl', PARAM_URL); + $mform->setType('externalurl', PARAM_TEXT); then the form starts to work as expected. The URL gets validated anyway in function "validation" in the same file.
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      wip-MDL-41921-master

      Description

      1. Add URL resource to course
      2. Inserting URL that needs trimming to "External URL" field (for example "http://example.com ")
      3. Click "Save and display" or "Save and return..."

      Expected result: trim the "External URL" value and save the resource.

      Actual result: resource not saved, "External URL" field empty and with error "Required".

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              marina Marina Glancy
              Reporter:
              mangus Mart Mangus
              Peer reviewer:
              Ankit Agarwal Ankit Agarwal
              Integrator:
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Tester:
              Frédéric Massart Frédéric Massart
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Nov/13