summaryrefslogtreecommitdiff
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-12-13 15:28:05 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2014-12-13 15:28:54 +0100
commit5ebf534ba7e90ccb12007c137ecea1cfcc4876da (patch)
tree7bee294ccb46e920288990d6fe1b2f6c46c2cd6f /web/lib
parentaa2724bbfee4b2504a4e9d27e06037639c3bc3cc (diff)
Avoid double slashes in notification email body
Refactor some of the URI generation code to avoid double slashes in absolute URIs. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/acctfuncs.inc.php2
-rw-r--r--web/lib/pkgbasefuncs.inc.php5
-rw-r--r--web/lib/pkgreqfuncs.inc.php12
-rw-r--r--web/lib/routing.inc.php23
4 files changed, 24 insertions, 18 deletions
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index 5e83f42..2d8dbaf 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -660,7 +660,7 @@ function send_resetkey($email, $subject, $body) {
/* Send e-mail with confirmation link. */
$body = wordwrap($body, 70);
- $body .= "\n\n". aur_location() . get_uri('/passreset/') .
+ $body .= "\n\n". get_uri('/passreset/', true) .
"?resetkey={$resetkey}";
$headers = "MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset=UTF-8\r\n" .
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 9cdd8a3..708f861 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -131,8 +131,7 @@ function pkgbase_add_comment($base_id, $uid, $comment) {
* work, users would be getting emails in the language that the
* user who posted the comment was in.
*/
- $body =
- 'from ' . aur_location() . get_pkgbase_uri($row['Name']) . "\n"
+ $body = 'from ' . get_pkgbase_uri($row['Name'], true) . "\n"
. username_from_sid($_COOKIE['AURSID']) . " wrote:\n\n"
. $comment
. "\n\n---\nIf you no longer wish to receive notifications about this package, please go the the above package page and click the UnNotify button.";
@@ -380,7 +379,7 @@ function pkgbase_flag($base_ids) {
$result = $dbh->query($q);
if ($result) {
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
- $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . aur_location() . get_pkgbase_uri($row['Name']) . "\n\n[1] - " . aur_location() . get_user_uri($f_name);
+ $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . get_pkgbase_uri($row['Name'], true) . "\n\n[1] - " . get_user_uri($f_name, true);
$body = wordwrap($body, 70);
$headers = "MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset=UTF-8\r\n" .
diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php
index e285477..a5d6be8 100644
--- a/web/lib/pkgreqfuncs.inc.php
+++ b/web/lib/pkgreqfuncs.inc.php
@@ -160,15 +160,15 @@ function pkgreq_file($ids, $type, $merge_into, $comments) {
$username . " [1] filed a request to merge " .
$row['Name'] . " [2] into " . $merge_into .
" [3]:\n\n" . $comments . "\n\n" .
- "[1] " . aur_location() . get_user_uri($username) . "\n" .
- "[2] " . aur_location() . get_pkgbase_uri($row['Name']) . "\n" .
- "[3] " . aur_location() . get_pkgbase_uri($merge_into) . "\n";
+ "[1] " . get_user_uri($username, true) . "\n" .
+ "[2] " . get_pkgbase_uri($row['Name'], true) . "\n" .
+ "[3] " . get_pkgbase_uri($merge_into, true) . "\n";
} else {
$body =
$username . " [1] filed a " . $type . " request for " .
$row['Name'] . " [2]:\n\n" . $comments . "\n\n" .
- "[1] " . aur_location() . get_user_uri($username) . "\n" .
- "[2] " . aur_location() . get_pkgbase_uri($row['Name']) . "\n";
+ "[1] " . get_user_uri($username, true) . "\n" .
+ "[2] " . get_pkgbase_uri($row['Name'], true) . "\n";
}
$body = wordwrap($body, 70);
$cc = array_unique($cc);
@@ -278,7 +278,7 @@ function pkgreq_close($id, $reason, $comments, $auto_close=false) {
}
if (!$auto_close) {
$body .= "\n";
- $body .= "[1] " . aur_location() . get_user_uri($username);
+ $body .= "[1] " . get_user_uri($username, true);
$body .= "\n";
}
$body = wordwrap($body, 70);
diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php
index 833ea0f..1ee2e35 100644
--- a/web/lib/routing.inc.php
+++ b/web/lib/routing.inc.php
@@ -37,8 +37,12 @@ function get_route($path) {
}
}
-function get_uri($path) {
- return $path;
+function get_uri($path, $absolute=false) {
+ if ($absolute) {
+ return rtrim(aur_location(), '/') . $path;
+ } else {
+ return $path;
+ }
}
function get_pkg_route() {
@@ -56,14 +60,16 @@ function get_pkgreq_route() {
return $PKGREQ_PATH;
}
-function get_pkg_uri($pkgname) {
+function get_pkg_uri($pkgname, $absolute=false) {
global $PKG_PATH;
- return $PKG_PATH . '/' . urlencode($pkgname) . '/';
+ $path = $PKG_PATH . '/' . urlencode($pkgname) . '/';
+ return get_uri($path, $absolute);
}
-function get_pkgbase_uri($pkgbase_name) {
+function get_pkgbase_uri($pkgbase_name, $absolute=false) {
global $PKGBASE_PATH;
- return $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/';
+ $path = $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/';
+ return get_uri($path, $absolute);
}
function get_user_route() {
@@ -71,7 +77,8 @@ function get_user_route() {
return $USER_PATH;
}
-function get_user_uri($username) {
+function get_user_uri($username, $absolute=false) {
global $USER_PATH;
- return $USER_PATH . '/' . urlencode($username) . '/';
+ $path = $USER_PATH . '/' . urlencode($username) . '/';
+ return get_uri($path, $absolute);
}