commit 8bdf57a7685246095d03e8edea018acad829fd95
parent 15a426b19a36a691ece4c007547735f1355fcc3f
Author: markseu <mark2011@mayberg.se>
Date: Sun, 25 Jan 2015 15:16:13 +0100
Core update (better link handling)
Diffstat:
4 files changed, 15 insertions(+), 29 deletions(-)
diff --git a/README.md b/README.md
@@ -1,4 +1,4 @@
-Yellow 0.4.22
+Yellow 0.4.23
=============
[](https://gitter.im/markseu/yellowcms)
diff --git a/system/core/core-webinterface.php b/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)
{
diff --git a/system/core/core.php b/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";
diff --git a/system/plugins/markdownextra.php b/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();