Ticket #1129: sanitize_tags-escape_string-in-inc.diff

File sanitize_tags-escape_string-in-inc.diff, 7.4 KB (added by Christian Beer, 13 years ago)

Changes to files in inc/ folder

  • uotd.inc

     
    3636    $user = lookup_user_id($profile->userid);
    3737    echo uotd_thumbnail($profile, $user);
    3838    echo user_links($user, true)."<br>";
    39     echo sub_sentence(output_transform(strip_tags($profile->response1)), ' ', 150, true);
     39    echo sub_sentence(output_transform(sanitize_tags($profile->response1)), ' ', 150, true);
    4040}
    4141
    4242// return the last UOTD profile, or null
     
    172172            $x .= uotd_thumbnail($profile, $user);
    173173            $x .= user_links($user);
    174174            $x .= "&nbsp;&nbsp;".
    175                 sub_sentence(strip_tags(output_transform($profile->response1)), ' ',
     175                sub_sentence(sanitize_tags(output_transform($profile->response1)), ' ',
    176176                             250, true);
    177177        }
    178178        else {
  • pm.inc

     
    128128}
    129129
    130130function pm_send($from_user, $to_user, $subject, $content, $send_email) {
    131     $sql_subject = boinc_real_escape_string(strip_tags($subject));
    132     $sql_content = boinc_real_escape_string($content);
     131    $sql_subject = BoincDb::escape_string(sanitize_tags($subject));
     132    $sql_content = BoincDb::escape_string($content);
    133133    $mid = BoincPrivateMessage::insert("(userid, senderid, date, subject, content) VALUES ($to_user->id, $from_user->id, UNIX_TIMESTAMP(), '$sql_subject', '$sql_content')");
    134134    if (!$mid) {
    135135        error_page(tra("Couldn't create message"));
  • forum.inc

     
    235235        if ($curpage > 0){
    236236            $navbar = '<a href="forum_forum.php?id='.$forum->id.'&start='.(($curpage-1)*THREADS_PER_PAGE);
    237237            if ($sort) $navbar.='&sort='.$sort;
    238             $navbar.= '"> &lt;-- Previous</a> ';
     238            $navbar.= '"> &lt;-- ".tra("Previous")."</a> ';
    239239        }
    240240       
    241241        // Display a list of pages surrounding this one
     
    256256        if ($curpage+1 < $total){
    257257            $navbar.= '<a href="forum_forum.php?id='.$forum->id.'&start='.(($curpage+1)*THREADS_PER_PAGE);
    258258            if ($sort) $navbar.='&sort='.$sort;
    259             $navbar.= '"> Next --&gt;</a>';
     259            $navbar.= '"> ".tra("Next")." --&gt;</a>';
    260260        }
    261261
    262262    }
     
    280280//  Process a user-supplied title to remove HTML stuff
    281281//
    282282function cleanup_title($title) {
    283     $x = strip_tags(bb2html($title));
     283    $x = sanitize_tags(bb2html($title));
    284284    $x = trim($x);
    285285    if (strlen($x)==0) return "(no title)";
    286286    else return $x;
     
    794794
    795795function create_thread($title, $content, $user, $forum, $signature, $export) {
    796796    $title = trim($title);
    797     $title = strip_tags($title);
     797    $title = sanitize_tags($title);
    798798    $title = mysql_real_escape_string($title);
    799799    $now = time();
    800800    $status = 0;
  • user.inc

     
    452452    if (!is_valid_country($country)) return null;
    453453
    454454    $email_addr = BoincDb::escape_string($email_addr);
    455     $name = strip_tags($name);
     455    $name = sanitize_tags($name);
    456456    $name = BoincDb::escape_string($name);
    457457    $passwd_hash = BoincDb::escape_string($passwd_hash);
    458458
    459459    $country = BoincDb::escape_string($country);
    460     $postal_code = strip_tags(BoincDb::escape_string($postal_code));
     460    $postal_code = sanitize_tags(BoincDb::escape_string($postal_code));
    461461
    462462    $uid = BoincUser::insert("(create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid,  send_email, show_hosts, cross_project_id, passwd_hash) values($now, '$email_addr', '$name', '$authenticator', '$country', '$postal_code', 0, 0, unix_timestamp(), '$project_prefs', $teamid, 1, 1, '$cross_project_id', '$passwd_hash')");
    463463
  • team.inc

     
    536536function make_team(
    537537    $userid, $name, $url, $type, $name_html, $description, $country
    538538) {
    539     $name = BoincDb::escape_string(strip_tags($name));
     539    $name = BoincDb::escape_string(sanitize_tags($name));
    540540    if (strlen($name) == 0) return null;
    541541    $name_lc = strtolower($name);
    542     $url = BoincDb::escape_string(strip_tags($url));
     542    $url = BoincDb::escape_string(sanitize_tags($url));
    543543    if (strstr($url, "http://")) {
    544544        $url = substr($url, 7);
    545545    }
  • forum_rss.inc

     
    4343    }
    4444    //$t = htmlspecialchars($t);
    4545    echo "<item>
    46         <title><![CDATA[".strip_tags(bb2html($thread->title))."]]></title>
     46        <title><![CDATA[".sanitize_tags(bb2html($thread->title))."]]></title>
    4747        <link>$unique_url</link>
    4848        <guid isPermaLink=\"true\">$unique_url</guid>
    4949        <description><![CDATA[\n$t\n]]></description>
  • profile.inc

     
    177177
    178178    if (strlen($profile->response1) != 0) {
    179179        $temp = $profile->response1;
    180         $description = "(\"" . sub_sentence(strip_tags($temp), ' ', MAX_DESC_LENGTH, true) . "\")";
     180        $description = "(\"" . sub_sentence(sanitize_tags($temp), ' ', MAX_DESC_LENGTH, true) . "\")";
    181181
    182182    }
    183183
  • util.inc

     
    133133) {
    134134    global $caching, $cache_control_extra, $did_page_head;
    135135
    136         $did_page_head = true;
     136    $did_page_head = true;
    137137    $stylesheet = URL_BASE.STYLESHEET;
    138138    $rssname = PROJECT . " RSS 2.0";
    139139    $rsslink = URL_BASE."rss_main.php";
     
    149149    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
    150150   
    151151    if (!$title_plain) {
    152         echo "<html><head><title>".strip_tags($title)."</title>\n";
     152        echo "<html><head><title>".sanitize_tags($title)."</title>\n";
    153153    } else {
    154         echo "<html><head><title>".strip_tags($title_plain)."</title>\n";
     154        echo "<html><head><title>".sanitize_tags($title_plain)."</title>\n";
    155155    }
    156156    echo "<link rel=stylesheet type=\"text/css\" href=\"".URL_BASE."main.css\" media=\"all\" />
    157157        <link rel=stylesheet type=\"text/css\" href=\"$stylesheet\">
  • db.inc

     
    7373}
    7474
    7575function lookup_user_name($name) {
     76    // TODO: is the following double escaped? Why?
    7677    $name = BoincDb::escape_string($name);
    7778    $users = BoincUser::enum("name='".boinc_real_escape_string($name)."'");
    7879    if (sizeof($users)==1) {
     
    110111    return BoincApp::lookup_id($id);
    111112}
    112113
     114// DEPRECATED: use BoincDb::escape_string where possible
     115//
    113116// apply this to any user-supplied strings used in queries
    114 //
     117// 
    115118function boinc_real_escape_string($x) {
    116119    if (version_compare(phpversion(),"4.3.0")>=0) {
    117120        return BoincDb::escape_string($x);