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

curl formatHeader does not cope with headers without values

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      • Run any behat test and ensure the is_server_running call (which happens at the start of the tests) does not produce any warning messages.
      • Ensure unitests are passing (specially filelib_test.php ones).
      • Exploratory testing: Ensure that interactions with external stuff using curl does continue working ok and does not lead to any "filelib" warning/notice:
        • External RSS feeds.
        • Badges backpack.
        • Wikimedia repository.
        • ...
      Show
      Run any behat test and ensure the is_server_running call (which happens at the start of the tests) does not produce any warning messages. Ensure unitests are passing (specially filelib_test.php ones). Exploratory testing: Ensure that interactions with external stuff using curl does continue working ok and does not lead to any "filelib" warning/notice: External RSS feeds. Badges backpack. Wikimedia repository. ...
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Pull Master Branch:
      MDL-47198_curl_header

      Description

      I've noticed that when running behat tests, the behat_util::is_server_running function makes a curl request, which, on my local set up, is returning this header (amongst other headers):

      Expires:

      As there is no value after the 'Expires:' key, the function formatHeader (in lib/filelib.php), produces a warning with this line:
      list($key, $value) = explode(" ", rtrim($header, "\r\n"), 2);

      Is it worth changing this line to:
      $parts = explode(" ", rtrim($header, "\r\n"), 2);
      $key = $parts[0];
      $value = null;
      if (isset($parts[1]))

      { $value = $parts[1]; }

      ?

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Jan/17