Bläddra i källkod

OPML import plus tolérant

Plus correction bug checkUrl()
Alexandre Alapetite 12 år sedan
förälder
incheckning
986c7297e7
2 ändrade filer med 13 tillägg och 6 borttagningar
  1. 1 1
      app/views/index/logs.phtml
  2. 12 5
      lib/lib_rss.php

+ 1 - 1
app/views/index/logs.phtml

@@ -14,7 +14,7 @@
 		<?php $this->logsPaginator->render ('logs_pagination.phtml', 'page'); ?>
 
 		<?php foreach ($items as $log) { ?>
-		<div class="log <?php echo $log->level (); ?>"><span class="date"><?php echo @date ('Y-m-d H:i:s', strtotime ($log->date ())); ?></span><?php echo htmlspecialchars ($log->info (), ENT_NOQUOTES, 'UTF-8'); ?></div>
+		<div class="log <?php echo $log->level (); ?>"><span class="date"><?php echo @date ('Y-m-d H:i:s', @strtotime ($log->date ())); ?></span><?php echo htmlspecialchars ($log->info (), ENT_NOQUOTES, 'UTF-8'); ?></div>
 		<?php } ?>
 
 		<?php $this->logsPaginator->render ('logs_pagination.phtml','page'); ?>

+ 12 - 5
lib/lib_rss.php

@@ -19,13 +19,13 @@ function checkUrl($url) {
 	if (empty ($url)) {
 		return '';
 	}
-	if (!preg_match ('#^https?://#i', $value)) {
+	if (!preg_match ('#^https?://#i', $url)) {
 		$url = 'http://' . $url;
 	}
 	if (filter_var($url, FILTER_VALIDATE_URL) ||
-		(version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($value, '-') > 0) &&	//PHP bug #51192
-		 ($value === filter_var($value, FILTER_SANITIZE_URL)))) {
-		return url;
+		(version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($url, '-') > 0) &&	//PHP bug #51192
+		 ($url === filter_var($url, FILTER_SANITIZE_URL)))) {
+		return $url;
 	} else {
 		return false;
 	}
@@ -113,7 +113,14 @@ function html_only_entity_decode($text) {
 
 function opml_import ($xml) {
 	$xml = html_only_entity_decode($xml);	//!\ Assume UTF-8
-	$opml = simplexml_load_string ($xml);
+
+	$dom = new DOMDocument();
+	$dom->recover = true;
+	$dom->strictErrorChecking = false;
+	$dom->loadXML($xml);
+	$this->encoding = 'UTF-8';
+
+	$opml = simplexml_import_dom($dom);
 
 	if (!$opml) {
 		throw new OpmlException ();