diff --git a/html/inc/consent.inc b/html/inc/consent.inc
index fda2b51b2d..94dead3b1c 100644
--- a/html/inc/consent.inc
+++ b/html/inc/consent.inc
@@ -48,7 +48,9 @@ function consent_to_a_policy(
function check_user_consent($user, $consent_name) {
list($checkct, $ctid) = check_consent_type($consent_name);
if ($checkct) {
- $consent_result = BoincLatestConsent::lookup("userid={$user->id} AND consent_type_id=$ctid AND consent_flag=1");
+ $consent_result = BoincLatestConsent::lookup(
+ "userid=$user->id AND consent_type_id=$ctid AND consent_flag=1"
+ );
if ($consent_result) {
return TRUE;
}
@@ -64,7 +66,8 @@ function check_user_consent($user, $consent_name) {
// If the boolean is FALSE, the integer returned is -1.
//
function check_consent_type($name, $checkenabled=TRUE) {
- $ct = BoincConsentType::lookup("shortname = '{$name}'");
+ $name = BoincDb::escape_string($name);
+ $ct = BoincConsentType::lookup("shortname = '$name'");
if ($ct and ( !$checkenabled or ($ct->enabled)) ) {
return array(TRUE, $ct->id);
}
diff --git a/html/inc/prefs_util.inc b/html/inc/prefs_util.inc
index 77ce73dd5f..4b2c6962d0 100644
--- a/html/inc/prefs_util.inc
+++ b/html/inc/prefs_util.inc
@@ -32,13 +32,13 @@ function check_venue($x) {
if ($x == "home") return;
if ($x == "work") return;
if ($x == "school") return;
- error_page(tra("bad venue: %1", $x));
+ error_page("bad venue");
}
function check_subset($x) {
if ($x == "global") return;
if ($x == "project") return;
- error_page(tra("bad subset: %1", $x));
+ error_page("bad subset");
}
abstract class PREF {
@@ -281,7 +281,7 @@ class PREF_CONSENT extends PREF {
$user, $consent_type_id, $flag, 0, 'Webform', time()
);
if (!$rc) {
- error_page(tra("Database error:").BoincDb::error());
+ error_page("Database error");
}
}
}
@@ -300,7 +300,7 @@ class PREF_CONSENT extends PREF {
$user, $consent_type_id, $this->default, 0, 'Webform'
);
if (!$rc) {
- error_page(tra("Database error:").BoincDb::error());
+ error_page("Database error");
}
}
diff --git a/html/inc/user_util.inc b/html/inc/user_util.inc
index 4d9179bb27..be6694f689 100644
--- a/html/inc/user_util.inc
+++ b/html/inc/user_util.inc
@@ -211,7 +211,7 @@ function validate_post_make_user() {
$team = BoincTeam::lookup_id($teamid);
$clone_user = BoincUser::lookup_id($team->userid);
if (!$clone_user) {
- error_page("User $userid not found");
+ error_page("User $team->userid not found");
}
$project_prefs = $clone_user->project_prefs;
} else {
diff --git a/html/inc/util.inc b/html/inc/util.inc
index b740c94cd4..ef5d98a04f 100644
--- a/html/inc/util.inc
+++ b/html/inc/util.inc
@@ -166,7 +166,11 @@ function send_cookie($name, $value, $permanent, $ops=false) {
$path .= "_ops/";
}
$expire = $permanent?time()+3600*24*365:0;
- setcookie($name, $value, $expire, $path);
+ setcookie($name, $value, $expire, $path,
+ '',
+ is_https(), // if this page is secure, make cookie secure
+ true // httponly; no JS access
+ );
}
function clear_cookie($name, $ops=false) {
@@ -887,10 +891,7 @@ function strip_bbcode($string){
}
function current_url() {
- $url = "http";
- if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
- $url .= "s";
- }
+ $url = is_https()?'https':'http';
$url .= "://";
$url .= $_SERVER['SERVER_NAME'];
$url .= ":".$_SERVER['SERVER_PORT'];
@@ -1107,7 +1108,7 @@ function do_download($path) {
function redirect_to_secure_url() {
if (defined('SECURE_URL_BASE')
&& strstr(SECURE_URL_BASE, "https://")
- && empty($_SERVER['HTTPS'])
+ && !is_https()
) {
Header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
exit;
diff --git a/html/inc/util_basic.inc b/html/inc/util_basic.inc
index 8785c24b11..754de0954d 100644
--- a/html/inc/util_basic.inc
+++ b/html/inc/util_basic.inc
@@ -200,6 +200,7 @@ function dtime() {
// is $x a valid file (or dir) name?
//
function is_valid_filename($x) {
+ if (htmlspecialchars($x) != $x) return false;
if (strstr($x, '/')) return false;
return true;
}
diff --git a/html/user/am_set_host_info.php b/html/user/am_set_host_info.php
index b05d4a6e2d..a99df5ed42 100644
--- a/html/user/am_set_host_info.php
+++ b/html/user/am_set_host_info.php
@@ -16,6 +16,8 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see
$notice
\n"; readfile($path); @@ -269,7 +284,7 @@ case 'delete_file': delete_file($user); break; case 'download_file': download_file($user); break; case 'view_file': view_file($user); break; case 'add_form': add_form($user); break; -default: error_page("no such action: $action"); +default: error_page("no such action: ".htmlspecialchars($action)); } ?> diff --git a/html/user/team_forum.php b/html/user/team_forum.php index 216ef8ba51..1e23bc64a9 100644 --- a/html/user/team_forum.php +++ b/html/user/team_forum.php @@ -205,7 +205,7 @@ if ($cmd == 'manage') { require_founder_login($user, $team); remove($team); } else if ($cmd != "") { - error_page("unknown command $cmd"); + error_page("unknown command ".htmlspecialchars($cmd)); } else { show_forum($team); } diff --git a/html/user/team_founder_transfer_action.php b/html/user/team_founder_transfer_action.php index 496e070175..9bffc5ee67 100644 --- a/html/user/team_founder_transfer_action.php +++ b/html/user/team_founder_transfer_action.php @@ -145,7 +145,7 @@ case "decline": } break; default: - error_page(tra("undefined action %1", $action)); + error_page("undefined action ".htmlspecialchars($action)); } echo "".tra("Return to team page")."";