mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 04:40:44 +02:00
Merge pull request #4067 from Deltik/fix-4054
Compliant query string ampersands in e_url
This commit is contained in:
@@ -3456,8 +3456,12 @@ class e107
|
||||
$options['fragment'] = '#' . $options['fragment'];
|
||||
}
|
||||
|
||||
if(!empty($tmp[$plugin][$key]['sef']))
|
||||
if (!empty($plugin) && empty($tmp[$plugin][$key]['sef']))
|
||||
{
|
||||
self::getMessage()->addDebug("e_url.php in <b>" . e_PLUGIN . $plugin . "</b> is missing the key: <b>" . $key . "</b>. Or, you may need to <a href='" . e_ADMIN . "db.php?mode=plugin_scan'>scan your plugin directories</a> to register e_url.php");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($tmp[$plugin][$key]['alias']))
|
||||
{
|
||||
$alias = (!empty($pref[e_LAN][$plugin][$key])) ? $pref[e_LAN][$plugin][$key] : $tmp[$plugin][$key]['alias'];
|
||||
@@ -3479,7 +3483,7 @@ class e107
|
||||
|
||||
$active = true;
|
||||
|
||||
foreach($matches[1] as $k=>$v) // check if a field value is missing, if so, revent to legacy url.
|
||||
foreach ($matches[1] as $k => $v) // check if a field value is missing, if so, revert to legacy url.
|
||||
{
|
||||
if (!isset($row[$v]))
|
||||
{
|
||||
@@ -3495,8 +3499,6 @@ class e107
|
||||
$active = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (deftrue('e_MOD_REWRITE') && ($active == true) && empty($options['legacy'])) // Search-Engine-Friendly URLs active.
|
||||
{
|
||||
$rawUrl = $tp->simpleParse($tmp[$plugin][$key]['sef'], $row);
|
||||
@@ -3513,13 +3515,6 @@ class e107
|
||||
{
|
||||
$sefUrl = e_HTTP . $rawUrl;
|
||||
}
|
||||
|
||||
// Append the query.
|
||||
if (is_array($options['query']) && !empty($options['query'])) {
|
||||
$sefUrl .= (strpos($sefUrl, '?') !== FALSE ? '&' : '?') . self::httpBuildQuery($options['query']);
|
||||
}
|
||||
|
||||
return $sefUrl . $options['fragment'];
|
||||
}
|
||||
else // Legacy URL.
|
||||
{
|
||||
@@ -3570,35 +3565,16 @@ class e107
|
||||
|
||||
}
|
||||
}
|
||||
$sefUrl = $legacyUrl;
|
||||
}
|
||||
|
||||
// Append the query.
|
||||
if (is_array($options['query']) && !empty($options['query']))
|
||||
{
|
||||
|
||||
$legacyUrl .= (strpos($legacyUrl, '?') !== FALSE ? '&' : '?') . self::httpBuildQuery($options['query']);
|
||||
$sefUrl .= (strpos($sefUrl, '?') !== FALSE ? '&' : '?') . self::httpBuildQuery($options['query']);
|
||||
}
|
||||
|
||||
return $legacyUrl . $options['fragment'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(!empty($plugin))
|
||||
{
|
||||
self::getMessage()->addDebug("e_url.php in <b>".e_PLUGIN.$plugin."</b> is missing the key: <b>".$key."</b>. Or, you may need to <a href='".e_ADMIN."db.php?mode=plugin_scan'>scan your plugin directories</a> to register e_url.php");
|
||||
}
|
||||
return false;
|
||||
|
||||
/*
|
||||
elseif(varset($tmp[$plugin][$key]['redirect']))
|
||||
{
|
||||
return self::getParser()->replaceConstants($tmp[$plugin][$key]['redirect'],'full');
|
||||
}
|
||||
|
||||
return;
|
||||
*/
|
||||
|
||||
return $sefUrl . $options['fragment'];
|
||||
}
|
||||
|
||||
|
||||
@@ -3643,7 +3619,7 @@ class e107
|
||||
* rawurlencode() (instead of urlencode()) all query parameters.
|
||||
* @param array $query The query parameter array to be processed, e.g. $_GET.
|
||||
* @param string $parent Internal use only. Used to build the $query array key for nested items.
|
||||
* @return array A rawurlencoded string which can be used as or appended to the URL query string.
|
||||
* @return string A rawurlencoded string which can be used as or appended to the URL query string.
|
||||
*/
|
||||
public static function httpBuildQuery(array $query, $parent = '')
|
||||
{
|
||||
@@ -3670,7 +3646,7 @@ class e107
|
||||
}
|
||||
}
|
||||
|
||||
return implode('&', $params);
|
||||
return implode('&', $params);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -140,6 +140,7 @@ class e_plugin
|
||||
{
|
||||
$this->_installed = array();
|
||||
$this->_addons = array();
|
||||
e107::setRegistry('core/e107/addons/e_url');
|
||||
|
||||
$this->_init(true);
|
||||
$this->_initIDs();
|
||||
|
@@ -791,10 +791,25 @@
|
||||
$result = $obj::url('news','index', array(), array('mode'=>'full'));
|
||||
|
||||
$this->assertEquals("https://localhost/e107/news", $result);
|
||||
// var_dump(SITEURL);
|
||||
}
|
||||
|
||||
|
||||
// $this->assertTrue($res);
|
||||
/**
|
||||
* @see https://github.com/e107inc/e107/issues/4054
|
||||
*/
|
||||
public function testUrlOptionQueryHasCompliantAmpersand()
|
||||
{
|
||||
$e107 = $this->e107;
|
||||
$e107::getPlugin()->install('forum');
|
||||
$url = $e107::url('forum', 'topic', [], array(
|
||||
'query' => array(
|
||||
'f' => 'post',
|
||||
'id' => 123
|
||||
),
|
||||
));
|
||||
$this->assertEquals(
|
||||
e_PLUGIN_ABS. 'forum/forum_viewtopic.php?f=post&id=123',
|
||||
$url, "Generated href does not match expectation"
|
||||
);
|
||||
}
|
||||
/*
|
||||
public function testRedirect()
|
||||
|
@@ -227,6 +227,7 @@
|
||||
|
||||
public function testGetFields()
|
||||
{
|
||||
e107::getPlugin()->uninstall('forum');
|
||||
$result = $this->ep->clearCache()->load('forum')->getFields(true);
|
||||
|
||||
// print_r($result);
|
||||
|
Reference in New Issue
Block a user