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

Details

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              christina_roperto Christina Thee Roperto
              bpinon Boris PINON
              cameron1729 cameron1729
              Andrew Lyons Andrew Lyons
              John Edward Pedregosa John Edward Pedregosa
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                22/Aug/22

                Time Tracking

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