mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
aa2724bbfe
commit
5ebf534ba7
6 changed files with 26 additions and 20 deletions
|
@ -48,7 +48,7 @@ html_header('AUR ' . __("Login"));
|
|||
<?php else: ?>
|
||||
<p>
|
||||
<?php printf(__("HTTP login is disabled. Please %sswitch to HTTPs%s if you want to login."),
|
||||
'<a href="' . aur_location() . get_uri('/login') . '">', '</a>'); ?>
|
||||
'<a href="' . get_uri('/login', true) . '">', '</a>'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -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" .
|
||||
|
|
|
@ -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" .
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -37,8 +37,12 @@ function get_route($path) {
|
|||
}
|
||||
}
|
||||
|
||||
function get_uri($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);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
<?php else: ?>
|
||||
<li><a href="<?= get_uri('/register/'); ?>"><?= __("Register"); ?></a></li>
|
||||
<?php if (config_get_bool('options', 'disable_http_login') && empty($_SERVER['HTTPS'])): ?>
|
||||
<li><a href="<?= aur_location() . get_uri('/login/'); ?>"><?= __("Login"); ?></a></li>
|
||||
<li><a href="<?= get_uri('/login/', true); ?>"><?= __("Login"); ?></a></li>
|
||||
<?php else: ?>
|
||||
<li><a href="<?= get_uri('/login/'); ?>"><?= __("Login"); ?></a></li>
|
||||
<?php endif; ?>
|
||||
|
|
Loading…
Add table
Reference in a new issue