-
Notifications
You must be signed in to change notification settings - Fork 393
Fix permanent_url for HTTP 301 #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Using cURL CURLOPT_FOLLOWLOCATION instead of the manual method in SimplePie hides the list of HTTP redirects along the way, and prevents the distinction of e.g. 301 vs. 302 redirects needed for `simplepie->subscribe_url(true)`. This patch disables CURLOPT_FOLLOWLOCATION in SimplePie, and fixes the manual method at the same time (curl_options where not given to following redirection requests). The use of CURLOPT_FOLLOWLOCATION was nevertheless not systematic (only when open_basedir was not set), so now there is only one logic independent of open_basedir.
| curl_setopt($fp, CURLOPT_REFERER, $url); | ||
| curl_setopt($fp, CURLOPT_USERAGENT, $useragent); | ||
| curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); | ||
| if (!ini_get('open_basedir') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those cURL options were only used in some configurations, and were problematic
| $this->redirects++; | ||
| $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); | ||
| $previousStatusCode = $this->status_code; | ||
| $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For configurations using the manual redirect method, the cURL options were lost.
|
Original code for HTTP 301 Moved Permanently b3e7227 |
|
thanks @Alkarex looks good to me. |
Using cURL CURLOPT_FOLLOWLOCATION instead of the manual method in SimplePie hides the list of HTTP redirects along the way, and prevents the distinction of e.g. 301 vs. 302 redirects needed for
simplepie->subscribe_url(true).This patch disables CURLOPT_FOLLOWLOCATION in SimplePie, and fixes the manual method at the same time (curl_options were not given to following redirection requests).
The use of CURLOPT_FOLLOWLOCATION was nevertheless not systematic (only when open_basedir was not set), so now there is only one logic independent of open_basedir.