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

curl::strip_double_headers only works with HTTP/1.0 or HTTP/1.1

XMLWordPrintable

    • MOODLE_310_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MDL-72349_update_strip_double_headers_function
    • Hide

      Prerequisites

      1. Run the ubuntu/squid Docker image:

        docker run -d --name squid-container -e TZ=UTC -p 3128:3128 ubuntu/squid:5.2-22.04_beta
        

      Testing

      1. In Moodle, navigate to: Server > HTTP
      2. Set "Proxy host" to "localhost", "Proxy port" to "3128", and "Proxy type" to "HTTP"
      3. Go to Site administration -> Plugins > Blocks > Manage blocks and turn on "Remote RSS feeds"
      4. Still on the same page (https:/site/admin/blocks.php), click on "Settings" for the "Remote RSS feeds" block
      5. Click Add/edit feeds > Add new feed
      6. In the feed URL enter: https://www.nasa.gov/rss/dyn/earth.rss
      7. Verify the feed adds correctly and you do not see any errors

      Regression testing

      1. Disable the proxy in Moodle:
        1. Navigate to: Server > HTTP
        2. Delete anything in the "Proxy host" and "Proxy port" fields and save
      2. Repeat the testing instructions from earlier
      Show
      Prerequisites Run the ubuntu/squid Docker image: docker run -d --name squid-container -e TZ=UTC -p 3128:3128 ubuntu/squid:5.2-22.04_beta Testing In Moodle, navigate to: Server > HTTP Set "Proxy host" to "localhost", "Proxy port" to "3128", and "Proxy type" to "HTTP" Go to Site administration -> Plugins > Blocks > Manage blocks and turn on "Remote RSS feeds" Still on the same page (https:/site/admin/blocks.php), click on "Settings" for the "Remote RSS feeds" block Click Add/edit feeds > Add new feed In the feed URL enter: https://www.nasa.gov/rss/dyn/earth.rss Verify the feed adds correctly and you do not see any errors Regression testing Disable the proxy in Moodle: Navigate to: Server > HTTP Delete anything in the "Proxy host" and "Proxy port" fields and save Repeat the testing instructions from earlier

      Replication steps

      Run the following code:

      <?php
       
      require_once('config.php');
      require_once($CFG->libdir.'/filelib.php');
       
      $headers = <<<EOF
      HTTP/1.0 200 Connection established
       
      HTTP/2 200 OK
      Date: Fri, 22 Feb 2013 17:14:23 GMT
      EOF;
       
      $rfc822lineendings = preg_replace("~(?!<\r)\n~", "\r\n", $headers);
      $stripped = curl::strip_double_headers($rfc822lineendings);
       
      echo "<pre>";
      echo $stripped;
      echo "</pre>";
      

      Expected result:

      HTTP/2 200 OK
      Date: Fri, 22 Feb 2013 17:14:23 GMT
      

      Actual result

      HTTP/1.0 200 Connection established
       
      HTTP/2 200 OK
      Date: Fri, 22 Feb 2013 17:14:23 GMT
      

      This causes problems with simplepie parsing headers when adding RSS feeds when Moodle is behind a proxy. For example; https://www.nasa.gov/rss/dyn/earth.rss (which responds with HTTP/2 200). Effectively hitting what was reported in MDL-38170

      Original report below:

      Hello,

      Since i have upgrade my Moodle to 3.10.5+, from time to time, i've got this message from my Moodle Cron :
      PHP Notice: Undefined index: content-type in /var/www/lib/simplepie/library/SimplePie.php on line 1648
      No errors detected from scheduled tasks. No interesting logs from the Moodle interface or from the server.
      Has anyone seen this problem before ?

      PS : my server is behind a web proxy

            christina_roperto Christina Thee Roperto
            bpinon Boris PINON
            cameron1729 cameron1729
            Andrew Lyons Andrew Lyons
            John Edward Pedregosa John Edward Pedregosa
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 45 minutes
                2h 45m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.