We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 3a6cb00a authored by Mike Sheldon's avatar Mike Sheldon

Fix URLs for artist/album/track names that contain + and / symbols

parent 2f6d447d
......@@ -29,6 +29,7 @@ require_once($install_path . '/utils/linkeddata.php');
require_once($install_path . '/utils/arc/ARC2.php');
require_once($install_path . '/utils/resolve-external.php');
require_once($install_path . '/utils/licenses.php');
require_once($install_path . '/utils/rewrite-encode.php');
require_once($install_path . '/temp-utils.php'); // this is extremely dodgy and shameful
/**
......@@ -315,7 +316,7 @@ class Server {
$component = '';
else
$component = "/{$component}";
return $base_url . '/user/' . urlencode($username) . $component;
return $base_url . '/user/' . rewrite_encode($username) . $component;
}
else
{
......@@ -326,7 +327,7 @@ class Server {
static function getGroupURL($groupname) {
global $friendly_urls, $base_url;
if($friendly_urls) {
return $base_url . '/group/' . urlencode($groupname);
return $base_url . '/group/' . rewrite_encode($groupname);
} else {
return $base_url . '/group.php?group=' . urlencode($groupname);
}
......@@ -335,7 +336,7 @@ class Server {
static function getArtistURL($artist, $component='') {
global $friendly_urls, $base_url;
if($friendly_urls) {
return $base_url . '/artist/' . urlencode($artist) . '/' . $component;
return $base_url . '/artist/' . rewrite_encode($artist) . '/' . $component;
} else {
if($component) {
return $base_url . '/artist-' . $component . '.php?artist=' . urlencode($artist);
......@@ -366,7 +367,7 @@ class Server {
static function getAlbumURL($artist, $album) {
global $friendly_urls, $base_url;
if($friendly_urls) {
return $base_url . '/artist/' . urlencode($artist) . '/album/' . urlencode($album);
return $base_url . '/artist/' . rewrite_encode($artist) . '/album/' . urlencode($album);
} else {
return $base_url . '/album.php?artist=' . urlencode($artist) . '&album=' . urlencode($album);
}
......@@ -385,9 +386,9 @@ class Server {
static function getTrackURL($artist, $album, $track) {
global $friendly_urls, $base_url;
if ($friendly_urls && $album) {
return $base_url . '/artist/' . urlencode($artist) . '/album/' . urlencode($album) . '/track/' . urlencode($track);
return $base_url . '/artist/' . rewrite_encode($artist) . '/album/' . rewrite_encode($album) . '/track/' . rewrite_encode($track);
} elseif ($friendly_urls) {
return $base_url . '/artist/' . urlencode($artist) . '/track/' . urlencode($track);
return $base_url . '/artist/' . rewrite_encode($artist) . '/track/' . rewrite_encode($track);
} else {
return $base_url . '/track.php?artist=' . urlencode($artist) . '&album=' . urlencode($album) . '&track=' . urlencode($track);
}
......@@ -396,9 +397,9 @@ class Server {
static function getTrackEditURL($artist, $album, $track) {
global $friendly_urls, $base_url;
if ($friendly_urls && $album) {
return $base_url . '/artist/' . urlencode($artist) . '/album/' . urlencode($album) . '/track/' . urlencode($track) . '/edit';
return $base_url . '/artist/' . rewrite_encode($artist) . '/album/' . rewrite_encode($album) . '/track/' . rewrite_encode($track) . '/edit';
} elseif ($friendly_urls) {
return $base_url . '/artist/' . urlencode($artist) . '/track/' . urlencode($track) . '/edit';
return $base_url . '/artist/' . rewrite_encode($artist) . '/track/' . rewrite_encode($track) . '/edit';
} else {
return $base_url . '/track-add.php?artist=' . urlencode($artist) . '&album=' . urlencode($album) . '&track=' . urlencode($track);
}
......@@ -407,7 +408,7 @@ class Server {
static function getTagURL($tag) {
global $friendly_urls, $base_url;
if ($friendly_urls) {
return $base_url . '/tag/' . urlencode($tag);
return $base_url . '/tag/' . rewrite_encode($tag);
} else {
return $base_url . '/tag.php?tag=' . urlencode($tag);
}
......
<?php
/* GNU FM -- a free network service for sharing your music listening habits
Copyright (C) 2009 Free Software Foundation, Inc
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Encodes an URL component in a mod_rewrite friendly way, handling plus and
* slash signs.
*
* @param string The text to encode
* @return string A mod_rewrite compatible encoding of the given text.
*/
function rewrite_encode($url) {
$url = urlencode($url);
$url = preg_replace('/%2B/', '%252B', $url);
$url = preg_replace('/%2F/', '%252F', $url);
return $url;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment