Browse Source

Core update (better link handling)

markseu 10 years ago
parent
commit
8bdf57a768
4 changed files with 15 additions and 29 deletions
  1. 1 1
      README.md
  2. 1 19
      system/core/core-webinterface.php
  3. 11 8
      system/core/core.php
  4. 2 1
      system/plugins/markdownextra.php

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-Yellow 0.4.22
+Yellow 0.4.23
 =============
 [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/markseu/yellowcms) 
 

+ 1 - 19
system/core/core-webinterface.php

@@ -5,7 +5,7 @@
 // Web interface core plugin
 class YellowWebinterface
 {
-	const Version = "0.4.8";
+	const Version = "0.4.9";
 	var $yellow;				//access to API
 	var $active;				//web interface is active? (boolean)
 	var $userLoginFailed;		//web interface login failed? (boolean)
@@ -71,24 +71,6 @@ class YellowWebinterface
 		}
 	}
 	
-	// Handle page content parsing
-	function onParseContent($page, $text)
-	{
-		$output = NULL;
-		if($this->isActive() && $this->isUser())
-		{
-			$serverBase = $this->yellow->config->get("serverBase");
-			$activePath = trim($this->yellow->config->get("webinterfaceLocation"), '/');
-			$callback = function($matches) use ($serverBase, $activePath)
-			{
-				$matches[2] = preg_replace("#^$serverBase/(?!$activePath)(.*)$#", "$serverBase/$activePath/$1", $matches[2]);
-				return "<a$matches[1]href=\"$matches[2]\"$matches[3]>";
-			};
-			$output = preg_replace_callback("/<a(.*?)href=\"([^\"]+)\"(.*?)>/i", $callback, $text);
-		}
-		return $output;
-	}
-	
 	// Handle page extra header
 	function onHeaderExtra($page)
 	{

+ 11 - 8
system/core/core.php

@@ -5,7 +5,7 @@
 // Yellow main class
 class Yellow
 {
-	const Version = "0.4.22";
+	const Version = "0.4.23";
 	var $page;				//current page
 	var $pages;				//pages from file system
 	var $config;			//configuration
@@ -1957,17 +1957,20 @@ class YellowToolbox
 	}
 	
 	// Normalise location, make absolute location
-	function normaliseLocation($location, $pageBase, $pageLocation, $filterStrict = true)
+	function normaliseLocation($location, $pageBase, $pageLocation, $staticLocation = "", $filterStrict = true)
 	{
 		if(!preg_match("/^\w+:/", trim(html_entity_decode($location, ENT_QUOTES, "UTF-8"))))
 		{
-			if(preg_match("/^\#/", $location))
+			if(empty($staticLocation) || !preg_match("#^$staticLocation#", $location))
 			{
-				$location = $pageBase.$pageLocation.$location;
-			} else if(!preg_match("/^\//", $location)) {
-				$location = $this->getDirectoryLocation($pageBase.$pageLocation).$location;
-			} else if(!preg_match("#^$pageBase#", $location)) {
-				$location = $pageBase.$location;
+				if(preg_match("/^\#/", $location))
+				{
+					$location = $pageBase.$pageLocation.$location;
+				} else if(!preg_match("/^\//", $location)) {
+					$location = $this->getDirectoryLocation($pageBase.$pageLocation).$location;
+				} else if(!preg_match("#^$pageBase#", $location)) {
+					$location = $pageBase.$location;
+				}
 			}
 		} else {
 			if($filterStrict && !preg_match("/^(http|https|ftp|mailto):/", $location)) $location = "error-xss-filter";

+ 2 - 1
system/plugins/markdownextra.php

@@ -5,7 +5,7 @@
 // Markdown extra plugin
 class YellowMarkdownExtra
 {
-	const Version = "0.4.2";
+	const Version = "0.4.3";
 	var $yellow;		//access to API
 	
 	// Handle plugin initialisation
@@ -39,6 +39,7 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
 		$this->url_filter_func = function($url) use ($yellow, $page)
 		{
 			return $yellow->toolbox->normaliseLocation($url, $page->base, $page->location,
+				$yellow->config->get("serverBase").$yellow->config->get("imageLocation"),
 				$page->parserSafeMode && $page->statusCode==200);
 		};
 		parent::__construct();