summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-10 10:20:07 +0400
committerAndrew Dolgov <[email protected]>2013-04-10 10:20:07 +0400
commit81a6a6a5ccb16d976091ce2195a242f646e9a492 (patch)
tree54533605c149f8ba91828dbdffbdf596e3394635
parent526f69066412ea628247d7f3e2f81c78310d9559 (diff)
parent6201154848d1bfdee74e98f4816b18a3495a4cb3 (diff)
Merge branch 'master' of github.com:gothfox/Tiny-Tiny-RSS
-rw-r--r--include/functions.php15
-rw-r--r--plugins/import_export/init.php1
2 files changed, 14 insertions, 2 deletions
diff --git a/include/functions.php b/include/functions.php
index ddb719507..4ac4e0968 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -7,6 +7,7 @@
$fetch_last_error = false;
$fetch_last_error_code = false;
+ $fetch_last_content_type = false;
$pluginhost = false;
function __autoload($class) {
@@ -317,6 +318,7 @@
global $fetch_last_error;
global $fetch_last_error_code;
+ global $fetch_last_content_type;
$url = str_replace(' ', '%20', $url);
@@ -367,11 +369,11 @@
}
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
+ $fetch_last_content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$fetch_last_error_code = $http_code;
- if ($http_code != 200 || $type && strpos($content_type, "$type") === false) {
+ if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) {
if (curl_errno($ch) != 0) {
$fetch_last_error = curl_errno($ch) . " " . curl_error($ch);
} else {
@@ -399,6 +401,15 @@
$data = @file_get_contents($url);
+ $fetch_last_content_type = false; // reset if no type was sent from server
+ foreach ($http_response_header as $h) {
+ if (substr(strtolower($h), 0, 13) == 'content-type:') {
+ $fetch_last_content_type = substr($h, 14);
+ // don't abort here b/c there might be more than one
+ // e.g. if we were being redirected -- last one is the right one
+ }
+ }
+
if (!$data && function_exists('error_get_last')) {
$error = error_get_last();
$fetch_last_error = $error["message"];
diff --git a/plugins/import_export/init.php b/plugins/import_export/init.php
index ab47288b3..1d7a8e55f 100644
--- a/plugins/import_export/init.php
+++ b/plugins/import_export/init.php
@@ -162,6 +162,7 @@ class Import_Export extends Plugin implements IHandler {
fputs($fp, "<article>");
foreach ($line as $k => $v) {
+ $v = str_replace("]]>", "]]]]><![CDATA[>", $v);
fputs($fp, "<$k><![CDATA[$v]]></$k>");
}