projects
/
tweeper.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/Tweeper.php: make code more robust by properly check return values
[tweeper.git]
/
src
/
Tweeper.php
diff --git
a/src/Tweeper.php
b/src/Tweeper.php
index
cfa3812
..
22d16ab
100644
(file)
--- a/
src/Tweeper.php
+++ b/
src/Tweeper.php
@@
-124,7
+124,14
@@
class Tweeper {
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_USERAGENT => Tweeper::$userAgent,
));
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_USERAGENT => Tweeper::$userAgent,
));
- curl_exec($ch);
+
+ $ret = curl_exec($ch);
+ if (FALSE === $ret) {
+ trigger_error(curl_error($ch));
+ curl_close($ch);
+ return FALSE;
+ }
+
$url_info = curl_getinfo($ch);
if (FALSE === $url_info) {
trigger_error(curl_error($ch));
$url_info = curl_getinfo($ch);
if (FALSE === $url_info) {
trigger_error(curl_error($ch));
@@
-160,6
+167,10
@@
class Tweeper {
);
$url_info = Tweeper::getUrlInfo($url);
);
$url_info = Tweeper::getUrlInfo($url);
+ if (FALSE === $url_info) {
+ error_log("Failed to retrieve info for URL: " . $url);
+ return '';
+ }
$supported = in_array($url_info['content_type'], $supported_content_types);
if (!$supported) {
$supported = in_array($url_info['content_type'], $supported_content_types);
if (!$supported) {
@@
-320,6
+331,9
@@
class Tweeper {
}
$stylesheet_contents = Tweeper::getUrlContents($stylesheet);
}
$stylesheet_contents = Tweeper::getUrlContents($stylesheet);
+ if (FALSE === $stylesheet_contents) {
+ return NULL;
+ }
$xslDoc = new DOMDocument();
$xslDoc->loadXML($stylesheet_contents);
$xslDoc = new DOMDocument();
$xslDoc->loadXML($stylesheet_contents);