Refactor all calls of p::clean() to SafeString::of() and p::purify() to SafeString::purify().

Removing any p::clean() calls for arguments to t() and t2() since their args are wrapped in a SafeString anyway.
This commit is contained in:
Andy Staudacher
2009-08-29 12:48:40 -07:00
parent a10063ff68
commit c01ac42c46
59 changed files with 159 additions and 188 deletions
+4 -4
View File
@@ -39,9 +39,9 @@ class Comments_Controller extends REST_Controller {
foreach ($comments as $comment) {
$data[] = array(
"id" => $comment->id,
"author_name" => p::clean($comment->author_name()),
"author_name" => SafeString::of($comment->author_name()),
"created" => $comment->created,
"text" => nl2br(p::purify($comment->text)));
"text" => nl2br(SafeString::purify($comment->text)));
}
print json_encode($data);
break;
@@ -126,9 +126,9 @@ class Comments_Controller extends REST_Controller {
array("result" => "success",
"data" => array(
"id" => $comment->id,
"author_name" => p::clean($comment->author_name()),
"author_name" => SafeString::of($comment->author_name()),
"created" => $comment->created,
"text" => nl2br(p::purify($comment->text)))));
"text" => nl2br(SafeString::purify($comment->text)))));
} else {
$view = new Theme_View("comment.html", "fragment");
$view->comment = $comment;
+4 -4
View File
@@ -23,7 +23,7 @@ class comment_rss_Core {
$feeds["comment/newest"] = t("All new comments");
if ($item) {
$feeds["comment/item/$item->id"] =
t("Comments on %title", array("title" => p::purify($item->title)));
t("Comments on %title", array("title" => SafeString::purify($item->title)));
}
return $feeds;
}
@@ -53,13 +53,13 @@ class comment_rss_Core {
$item = $comment->item();
$feed->children[] = new ArrayObject(
array("pub_date" => date("D, d M Y H:i:s T", $comment->created),
"text" => nl2br(p::purify($comment->text)),
"text" => nl2br(SafeString::purify($comment->text)),
"thumb_url" => $item->thumb_url(),
"thumb_height" => $item->thumb_height,
"thumb_width" => $item->thumb_width,
"item_uri" => url::abs_site("{$item->type}s/$item->id"),
"title" => p::purify($item->title),
"author" => p::clean($comment->author_name())),
"title" => SafeString::purify($item->title),
"author" => SafeString::of($comment->author_name())),
ArrayObject::ARRAY_AS_PROPS);
}
@@ -4,13 +4,13 @@
<li class="<?= ($i % 2 == 0) ? "gEvenRow" : "gOddRow" ?>">
<img src="<?= $comment->author()->avatar_url(32, $theme->url("images/avatar.jpg", true)) ?>"
class="gAvatar"
alt="<?= p::clean($comment->author_name()) ?>"
alt="<?= SafeString::of($comment->author_name()) ?>"
width="32"
height="32" />
<?= gallery::date_time($comment->created) ?>
<?= t('<a href="#">%author_name</a> said <em>%comment_text</em>',
array("author_name" => p::clean($comment->author_name()),
"comment_text" => text::limit_words(nl2br(p::purify($comment->text)), 50))); ?>
array("author_name" => SafeString::of($comment->author_name()),
"comment_text" => text::limit_words(nl2br(SafeString::purify($comment->text)), 50))); ?>
</li>
<? endforeach ?>
</ul>
@@ -108,12 +108,12 @@
<a href="#">
<img src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>"
class="gAvatar"
alt="<?= p::clean($comment->author_name()) ?>"
alt="<?= SafeString::of($comment->author_name()) ?>"
width="40"
height="40" />
</a>
<p><a href="mailto:<?= p::clean($comment->author_email()) ?>"
title="<?= p::clean($comment->author_email()) ?>"> <?= p::clean($comment->author_name()) ?> </a></p>
<p><a href="mailto:<?= SafeString::of($comment->author_email()) ?>"
title="<?= SafeString::of($comment->author_email()) ?>"> <?= SafeString::of($comment->author_name()) ?> </a></p>
</td>
<td>
<div class="right">
@@ -122,7 +122,7 @@
<a href="<?= $item->url() ?>">
<? if ($item->has_thumb()): ?>
<img src="<?= $item->thumb_url() ?>"
alt="<?= p::purify($item->title) ?>"
alt="<?= SafeString::purify($item->title) ?>"
<?= photo::img_dimensions($item->thumb_width, $item->thumb_height, 75) ?>
/>
<? else: ?>
@@ -132,7 +132,7 @@
</div>
</div>
<p><?= gallery::date($comment->created) ?></p>
<?= nl2br(p::purify($comment->text)) ?>
<?= nl2br(SafeString::purify($comment->text)) ?>
</td>
<td>
<ul class="gButtonSetVertical">
+3 -3
View File
@@ -4,15 +4,15 @@
<a href="#">
<img src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>"
class="gAvatar"
alt="<?= p::clean($comment->author_name()) ?>"
alt="<?= SafeString::of($comment->author_name()) ?>"
width="40"
height="40" />
</a>
<?= t("on %date_time, %author_name said",
array("date_time" => gallery::date_time($comment->created),
"author_name" => p::clean($comment->author_name()))) ?>
"author_name" => SafeString::of($comment->author_name()))) ?>
</p>
<div>
<?= nl2br(p::purify($comment->text)) ?>
<?= nl2br(SafeString::purify($comment->text)) ?>
</div>
</li>
+6 -6
View File
@@ -6,9 +6,9 @@
xmlns:fh="http://purl.org/syndication/history/1.0">
<channel>
<generator>Gallery 3</generator>
<title><?= p::clean($feed->title) ?></title>
<title><?= SafeString::of($feed->title) ?></title>
<link><?= $feed->uri ?></link>
<description><?= p::clean($feed->description) ?></description>
<description><?= SafeString::of($feed->description) ?></description>
<language>en-us</language>
<atom:link rel="self" href="<?= $feed->uri ?>" type="application/rss+xml" />
<fh:complete/>
@@ -22,14 +22,14 @@
<lastBuildDate><?= $pub_date ?></lastBuildDate>
<? foreach ($feed->children as $child): ?>
<item>
<title><?= p::purify($child->title) ?></title>
<link><?= p::clean($child->item_uri) ?></link>
<author><?= p::clean($child->author) ?></author>
<title><?= SafeString::purify($child->title) ?></title>
<link><?= SafeString::of($child->item_uri) ?></link>
<author><?= SafeString::of($child->author) ?></author>
<guid isPermaLink="true"><?= $child->item_uri ?></guid>
<pubDate><?= $child->pub_date ?></pubDate>
<content:encoded>
<![CDATA[
<p><?= nl2br(p::purify($child->text)) ?></p>
<p><?= nl2br(SafeString::purify($child->text)) ?></p>
<p>
<img alt="" src="<?= $child->thumb_url ?>"
height="<?= $child->thumb_height ?>" width="<?= $child->thumb_width ?>" />
+3 -3
View File
@@ -12,16 +12,16 @@
<a href="#">
<img src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>"
class="gAvatar"
alt="<?= p::clean($comment->author_name()) ?>"
alt="<?= SafeString::of($comment->author_name()) ?>"
width="40"
height="40" />
</a>
<?= t('on %date <a href="#">%name</a> said',
array("date" => date("Y-M-d H:i:s", $comment->created),
"name" => p::clean($comment->author_name()))); ?>
"name" => SafeString::of($comment->author_name()))); ?>
</p>
<div>
<?= nl2br(p::purify($comment->text)) ?>
<?= nl2br(SafeString::purify($comment->text)) ?>
</div>
</li>
<? endforeach ?>
+1 -1
View File
@@ -50,7 +50,7 @@ class Digibug_Controller extends Controller {
"image_width_1" => $item->width,
"thumb_height_1" => $item->thumb_height,
"thumb_width_1" => $item->thumb_width,
"title_1" => p::purify($item->title));
"title_1" => SafeString::purify($item->title));
print $v;
}
+2 -2
View File
@@ -14,14 +14,14 @@
<?= $details[$i]["caption"] ?>
</td>
<td class="gOdd">
<?= p::clean($details[$i]["value"]) ?>
<?= SafeString::of($details[$i]["value"]) ?>
</td>
<? if (!empty($details[++$i])): ?>
<td class="gEven">
<?= $details[$i]["caption"] ?>
</td>
<td class="gOdd">
<?= p::clean($details[$i]["value"]) ?>
<?= SafeString::of($details[$i]["value"]) ?>
</td>
<? else: ?>
<td class="gEven"></td><td class="gOdd"></td>
+1 -1
View File
@@ -590,7 +590,7 @@ class g2_import_Core {
self::map($g2_comment->getId(), $comment->id);
return t("Imported comment '%comment' for item with id: %id",
array("id" => $comment->item_id,
"comment" => text::limit_words(nl2br(p::purify($comment->text)), 50)));
"comment" => text::limit_words(nl2br(SafeString::purify($comment->text)), 50)));
}
/**
@@ -46,7 +46,7 @@ class Admin_Advanced_Settings_Controller extends Admin_Controller {
module::set_var($module_name, $var_name, Input::instance()->post("value"));
message::success(
t("Saved value for %var (%module_name)",
array("var" => p::clean($var_name), "module_name" => $module_name)));
array("var" => SafeString::of($var_name), "module_name" => $module_name)));
print json_encode(array("result" => "success"));
}
+1 -1
View File
@@ -93,7 +93,7 @@ class Movies_Controller extends Items_Controller {
log::success("content", "Updated photo", "<a href=\"photos/$photo->id\">view</a>");
message::success(
t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title))));
t("Saved photo %photo_title", array("photo_title" => $photo->title)));
print json_encode(
array("result" => "success",
+1 -1
View File
@@ -86,7 +86,7 @@ class Photos_Controller extends Items_Controller {
log::success("content", "Updated photo", "<a href=\"photos/$photo->id\">view</a>");
message::success(
t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title))));
t("Saved photo %photo_title", array("photo_title" => $photo->title)));
print json_encode(
array("result" => "success",
+5 -5
View File
@@ -89,7 +89,7 @@ class Quick_Controller extends Controller {
access::required("view", $item->parent());
access::required("edit", $item->parent());
$msg = t("Made <b>%title</b> this album's cover", array("title" => p::purify($item->title)));
$msg = t("Made <b>%title</b> this album's cover", array("title" => SafeString::purify($item->title)));
item::make_album_cover($item);
message::success($msg);
@@ -105,10 +105,10 @@ class Quick_Controller extends Controller {
if ($item->is_album()) {
print t(
"Delete the album <b>%title</b>? All photos and movies in the album will also be deleted.",
array("title" => p::purify($item->title)));
array("title" => SafeString::purify($item->title)));
} else {
print t("Are you sure you want to delete <b>%title</b>?",
array("title" => p::purify($item->title)));
array("title" => SafeString::purify($item->title)));
}
$form = item::get_delete_form($item);
@@ -122,9 +122,9 @@ class Quick_Controller extends Controller {
access::required("edit", $item);
if ($item->is_album()) {
$msg = t("Deleted album <b>%title</b>", array("title" => p::purify($item->title)));
$msg = t("Deleted album <b>%title</b>", array("title" => SafeString::purify($item->title)));
} else {
$msg = t("Deleted photo <b>%title</b>", array("title" => p::purify($item->title)));
$msg = t("Deleted photo <b>%title</b>", array("title" => SafeString::purify($item->title)));
}
$parent = $item->parent();
+2 -2
View File
@@ -52,9 +52,9 @@ class gallery_rss_Core {
->viewable()
->descendants($limit, $offset, "photo");
$feed->max_pages = ceil($item->viewable()->descendants_count("photo") / $limit);
$feed->title = p::purify($item->title);
$feed->title = SafeString::purify($item->title);
$feed->link = url::abs_site("albums/{$item->id}");
$feed->description = nl2br(p::purify($item->description));
$feed->description = nl2br(SafeString::purify($item->description));
return $feed;
}
+2 -2
View File
@@ -64,10 +64,10 @@ class gallery_task_Core {
if (!$success) {
$ignored[$item->id] = 1;
$errors[] = t("Unable to rebuild images for '%title'",
array("title" => p::purify($item->title)));
array("title" => SafeString::purify($item->title)));
} else {
$errors[] = t("Successfully rebuilt images for '%title'",
array("title" => p::purify($item->title)));
array("title" => SafeString::purify($item->title)));
}
}
-29
View File
@@ -1,29 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class p_Core {
static function clean($dirty_html) {
return new SafeString($dirty_html);
}
// Deprecated: Please use p::clean($var).purified_html()
static function purify($dirty_html) {
return SafeString::of($dirty_html)->purified_html();
}
}
@@ -20,13 +20,13 @@
<? if ($var->module_name == "gallery" && $var->name == "_cache") continue ?>
<tr class="setting">
<td> <?= $var->module_name ?> </td>
<td> <?= p::clean($var->name) ?> </td>
<td> <?= SafeString::of($var->name) ?> </td>
<td>
<a href="<?= url::site("admin/advanced_settings/edit/$var->module_name/" . p::clean($var->name)) ?>"
<a href="<?= url::site("admin/advanced_settings/edit/$var->module_name/" . SafeString::of($var->name)) ?>"
class="gDialogLink"
title="<?= t("Edit %var (%module_name)", array("var" => p::clean($var->name), "module_name" => $var->module_name)) ?>">
title="<?= t("Edit %var (%module_name)", array("var" => $var->name, "module_name" => $var->module_name)) ?>">
<? if ($var->value): ?>
<?= p::clean($var->value) ?>
<?= SafeString::of($var->value) ?>
<? else: ?>
<i> <?= t("empty") ?> </i>
<? endif ?>
@@ -2,7 +2,7 @@
<ul>
<? foreach ($entries as $entry): ?>
<li class="<?= log::severity_class($entry->severity) ?>" style="direction: ltr">
<a href="<?= url::site("user/$entry->user_id") ?>"><?= p::clean($entry->user->name) ?></a>
<a href="<?= url::site("user/$entry->user_id") ?>"><?= SafeString::of($entry->user->name) ?></a>
<?= gallery::date_time($entry->timestamp) ?>
<?= $entry->message ?>
<?= $entry->html ?>
@@ -2,9 +2,9 @@
<ul>
<? foreach ($photos as $photo): ?>
<li class="gItem gPhoto">
<a href="<?= url::site("photos/$photo->id") ?>" title="<?= p::clean($photo->title) ?>">
<a href="<?= url::site("photos/$photo->id") ?>" title="<?= SafeString::of($photo->title) ?>">
<img <?= photo::img_dimensions($photo->width, $photo->height, 72) ?>
src="<?= $photo->thumb_url() ?>" alt="<?= p::clean($photo->title) ?>" />
src="<?= $photo->thumb_url() ?>" alt="<?= SafeString::of($photo->title) ?>" />
</a>
</li>
<? endforeach ?>
@@ -90,7 +90,7 @@
<?= $task->status ?>
</td>
<td>
<?= p::clean($task->owner()->name) ?>
<?= SafeString::of($task->owner()->name) ?>
</td>
<td>
<? if ($task->state == "stalled"): ?>
@@ -12,7 +12,7 @@ appendTo('body').submit().remove();
<div id="gTaskLogDialog">
<h1> <?= $task->name ?> </h1>
<div class="gTaskLog">
<pre><?= p::purify($task->get_log()) ?></pre>
<pre><?= SafeString::purify($task->get_log()) ?></pre>
</div>
<button id="gCloseButton" class="ui-state-default ui-corner-all" onclick="dismiss()"><?= t("Close") ?></button>
<button id="gSaveButton" class="ui-state-default ui-corner-all" onclick="download()"><?= t("Save") ?></button>
+1 -1
View File
@@ -8,7 +8,7 @@
</p>
<p>
<?= t("You're logged in to the <b>%user_name</b> account. The very first thing you should do is to change your password to something that you'll remember.", array("user_name" => p::clean($user->name))) ?>
<?= t("You're logged in to the <b>%user_name</b> account. The very first thing you should do is to change your password to something that you'll remember.", array("user_name" => $user->name)) ?>
</p>
<p>
+4 -4
View File
@@ -1,18 +1,18 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?= $parent->thumb_img(array(), 25); ?>
<? if (!access::can("edit", $parent) || $source->is_descendant($parent)): ?>
<a href="javascript:load_tree('<?= $parent->id ?>',1)"> <?= p::clean($parent->title) ?> <?= t("(locked)") ?> </a>
<a href="javascript:load_tree('<?= $parent->id ?>',1)"> <?= SafeString::of($parent->title) ?> <?= t("(locked)") ?> </a>
<? else: ?>
<a href="javascript:load_tree('<?= $parent->id ?>',0)"> <?= p::clean($parent->title) ?></a>
<a href="javascript:load_tree('<?= $parent->id ?>',0)"> <?= SafeString::of($parent->title) ?></a>
<? endif ?>
<ul id="tree_<?= $parent->id ?>">
<? foreach ($children as $child): ?>
<li id="node_<?= $child->id ?>" class="node">
<?= $child->thumb_img(array(), 25); ?>
<? if (!access::can("edit", $child) || $source->is_descendant($child)): ?>
<a href="javascript:load_tree('<?= $child->id ?>',1)"> <?= p::clean($child->title) ?> <?= t("(locked)") ?></a>
<a href="javascript:load_tree('<?= $child->id ?>',1)"> <?= SafeString::of($child->title) ?> <?= t("(locked)") ?></a>
<? else: ?>
<a href="javascript:load_tree('<?= $child->id ?>',0)"> <?= p::clean($child->title) ?> </a>
<a href="javascript:load_tree('<?= $child->id ?>',0)"> <?= SafeString::of($child->title) ?> </a>
<? endif ?>
</li>
<? endforeach ?>
@@ -35,14 +35,14 @@
<? foreach ($parents as $parent): ?>
<li>
<a href="javascript:show(<?= $parent->id ?>)">
<?= p::clean($parent->title) ?>
<?= SafeString::of($parent->title) ?>
</a>
<div class="form" id="edit-<?= $parent->id ?>"></div>
<ul>
<? endforeach ?>
<li>
<a href="javascript:show(<?= $item->id ?>)">
<?= p::purify($item->title) ?>
<?= SafeString::purify($item->title) ?>
</a>
<div class="form" id="edit-<?= $item->id ?>">
<?= $form ?>
@@ -6,7 +6,7 @@
<tr>
<th> </th>
<? foreach ($groups as $group): ?>
<th> <?= p::clean($group->name) ?> </th>
<th> <?= SafeString::of($group->name) ?> </th>
<? endforeach ?>
</tr>
@@ -6,7 +6,7 @@
<!-- hack to set the title for the dialog -->
<form id="gAddPhotosForm" action="<?= url::site("simple_uploader/finish?csrf=$csrf") ?>">
<fieldset>
<legend> <?= t("Add photos to %album_title", array("album_title" => p::purify($item->title))) ?> </legend>
<legend> <?= t("Add photos to %album_title", array("album_title" => SafeString::purify($item->title))) ?> </legend>
</fieldset>
</form>
@@ -26,9 +26,9 @@
</p>
<ul class="gBreadcrumbs">
<? foreach ($item->parents() as $parent): ?>
<li> <?= p::clean($parent->title) ?> </li>
<li> <?= SafeString::of($parent->title) ?> </li>
<? endforeach ?>
<li class="active"> <?= p::purify($item->title) ?> </li>
<li class="active"> <?= SafeString::purify($item->title) ?> </li>
</ul>
<p>
+5 -5
View File
@@ -2,18 +2,18 @@
<ul class="gMetadata">
<li>
<strong class="caption"><?= t("Title:") ?></strong>
<?= p::purify($item->title) ?>
<?= SafeString::purify($item->title) ?>
</li>
<? if ($item->description): ?>
<li>
<strong class="caption"><?= t("Description:") ?></strong>
<?= nl2br(p::purify($item->description)) ?>
<?= nl2br(SafeString::purify($item->description)) ?>
</li>
<? endif ?>
<? if ($item->id != 1): ?>
<li>
<strong class="caption"><?= t("Folder name:") ?></strong>
<?= p::clean($item->name) ?>
<?= SafeString::of($item->name) ?>
</li>
<? endif ?>
<? if ($item->captured): ?>
@@ -26,9 +26,9 @@
<li>
<strong class="caption"><?= t("Owner:") ?></strong>
<? if ($item->owner->url): ?>
<a href="<?= $item->owner->url ?>"><?= p::clean($item->owner->display_name()) ?></a>
<a href="<?= $item->owner->url ?>"><?= SafeString::of($item->owner->display_name()) ?></a>
<? else: ?>
<?= p::clean($item->owner->display_name()) ?>
<?= SafeString::of($item->owner->display_name()) ?>
<? endif ?>
</li>
<? endif ?>
@@ -1,26 +1,26 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<html>
<head>
<title><?= p::clean($subject) ?> </title>
<title><?= SafeString::of($subject) ?> </title>
</head>
<body>
<h2><?= p::clean($subject) ?></h2>
<h2><?= SafeString::of($subject) ?></h2>
<table>
<tr>
<td><?= t("Comment:") ?></td>
<td><?= nl2br(p::purify($comment->text)) ?></td>
<td><?= nl2br(SafeString::purify($comment->text)) ?></td>
</tr>
<tr>
<td><?= t("Author Name:") ?></td>
<td><?= p::clean($comment->author_name()) ?></td>
<td><?= SafeString::of($comment->author_name()) ?></td>
</tr>
<tr>
<td><?= t("Author Email:") ?></td>
<td><?= p::clean($comment->author_email()) ?></td>
<td><?= SafeString::of($comment->author_email()) ?></td>
</tr>
<tr>
<td><?= t("Author URL:") ?></td>
<td><?= p::clean($comment->author_url()) ?></td>
<td><?= SafeString::of($comment->author_url()) ?></td>
</tr>
<tr>
<td><?= t("Url:") ?></td>
@@ -1,14 +1,14 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<html>
<head>
<title><?= p::clean($subject) ?> </title>
<title><?= SafeString::of($subject) ?> </title>
</head>
<body>
<h2><?= p::clean($subject) ?></h2>
<h2><?= SafeString::of($subject) ?></h2>
<table>
<tr>
<td><?= t("Title:") ?></td>
<td><?= p::purify($item->title) ?></td>
<td><?= SafeString::purify($item->title) ?></td>
</tr>
<tr>
<td><?= t("Url:") ?></td>
@@ -21,7 +21,7 @@
<? if ($item->description): ?>
<tr>
<td><?= t("Description:") ?></td>
<td><?= nl2br(p::purify($item->description)) ?></td>
<td><?= nl2br(SafeString::purify($item->description)) ?></td>
</tr>
<? endif ?>
</table>
@@ -1,15 +1,15 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<html>
<head>
<title><?= p::clean($subject) ?> </title>
<title><?= SafeString::of($subject) ?> </title>
</head>
<body>
<h2><?= p::clean($subject) ?></h2>
<h2><?= SafeString::of($subject) ?></h2>
<table>
<tr>
<td colspan="2">
<?= t("To view the changed album %title use the link below.",
array("title" => p::purify($item->parent()->title))) ?>
array("title" => SafeString::purify($item->parent()->title))) ?>
</td>
</tr>
<tr>
@@ -1,18 +1,18 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<html>
<head>
<title><?= p::clean($subject) ?> </title>
<title><?= SafeString::of($subject) ?> </title>
</head>
<body>
<h2> <?= p::clean($subject) ?> </h2>
<h2> <?= SafeString::of($subject) ?> </h2>
<table>
<tr>
<? if ($item->original("title") != $item->title): ?>
<td><?= t("New Title:") ?></td>
<td><?= p::clean($item->title) ?></td>
<td><?= SafeString::of($item->title) ?></td>
<? else: ?>
<td><?= t("Title:") ?></td>
<td><?= p::clean($item->title) ?></td>
<td><?= SafeString::of($item->title) ?></td>
<? endif ?>
</tr>
<tr>
@@ -22,12 +22,12 @@
<? if ($item->original("description") != $item->description): ?>
<tr>
<td><?= t("New Description:") ?></td>
<td><?= p::clean($item->description) ?></td>
<td><?= SafeString::of($item->description) ?></td>
</tr>
<? elseif (!empty($item->description)): ?>
<tr>
<td><?= t("Description:") ?></td>
<td><?= p::clean($item->description) ?></td>
<td><?= SafeString::of($item->description) ?></td>
</tr>
<? endif ?>
</table>
+5 -5
View File
@@ -62,8 +62,8 @@ class Organize_Controller extends Controller {
access::required("edit", $item);
print json_encode(
array("title" => p::purify($item->title),
"description" => empty($item->description) ? "" : p::purify($item->description)));
array("title" => SafeString::purify($item->title),
"description" => empty($item->description) ? "" : SafeString::purify($item->description)));
}
function tree($item, $parent) {
@@ -281,10 +281,10 @@ class Organize_Controller extends Controller {
if ($item->is_album()) {
log::success("content", "Updated album", "<a href=\"albums/$item->id\">view</a>");
$message = t("Saved album %album_title", array("album_title" => p::purify($item->title)));
$message = t("Saved album %album_title", array("album_title" => SafeString::purify($item->title)));
} else {
log::success("content", "Updated photo", "<a href=\"photos/$item->id\">view</a>");
$message = t("Saved photo %photo_title", array("photo_title" => p::purify($item->title)));
$message = t("Saved photo %photo_title", array("photo_title" => SafeString::purify($item->title)));
}
print json_encode(array("form" => $form->__toString(), "message" => $message));
} else {
@@ -321,7 +321,7 @@ class Organize_Controller extends Controller {
$item->save();
log::success("content", "Updated album", "<a href=\"albums/$item->id\">view</a>");
$message = t("Saved album %album_title", array("album_title" => p::purify($item->title)));
$message = t("Saved album %album_title", array("album_title" => SafeString::purify($item->title)));
print json_encode(array("form" => $form->__toString(), "message" => $message));
} else {
print json_encode(array("form" => $form->__toString()));
+1 -1
View File
@@ -16,7 +16,7 @@ var CONFIRM_DELETE = "<?= t("Do you really want to delete the selected albums an
});
</script>
<fieldset style="display: none">
<legend><?= t("Organize %name", array("name" => p::purify($item->title))) ?></legend>
<legend><?= t("Organize %name", array("name" => SafeString::purify($item->title))) ?></legend>
</fieldset>
<div id="doc3" class="yui-t7">
<div id="bd">
@@ -7,7 +7,7 @@
<div id="gOrganizeBranch-<?= $album->id ?>" ref="<?= $album->id ?>"
class="<?= $selected ? "gBranchSelected" : "" ?> gBranchText">
<?= p::clean($album->title) ?>
<?= SafeString::of($album->title) ?>
</div>
<div id="gOrganizeChildren-<?= $album->id ?>"
class="<?= $album_icon == "ui-icon-plus" ? "gBranchCollapsed" : "" ?>">
+7 -7
View File
@@ -6,9 +6,9 @@
xmlns:fh="http://purl.org/syndication/history/1.0">
<channel>
<generator>gallery3</generator>
<title><?= p::clean($feed->title) ?></title>
<title><?= SafeString::of($feed->title) ?></title>
<link><?= $feed->uri ?></link>
<description><?= p::clean($feed->description) ?></description>
<description><?= SafeString::of($feed->description) ?></description>
<language>en-us</language>
<atom:link rel="self" href="<?= $feed->uri ?>" type="application/rss+xml" />
<fh:complete/>
@@ -22,25 +22,25 @@
<lastBuildDate><?= $pub_date ?></lastBuildDate>
<? foreach ($feed->children as $child): ?>
<item>
<title><?= p::clean($child->title) ?></title>
<title><?= SafeString::of($child->title) ?></title>
<link><?= url::abs_site("{$child->type}s/{$child->id}") ?></link>
<guid isPermaLink="true"><?= url::abs_site("{$child->type}s/{$child->id}") ?></guid>
<pubDate><?= date("D, d M Y H:i:s T", $child->created); ?></pubDate>
<content:encoded>
<![CDATA[
<span><?= p::clean($child->description) ?></span>
<span><?= SafeString::of($child->description) ?></span>
<p>
<? if ($child->type == "photo" || $child->type == "album"): ?>
<img alt="" src="<?= $child->resize_url(true) ?>"
title="<?= p::clean($child->title) ?>"
title="<?= SafeString::of($child->title) ?>"
height="<?= $child->resize_height ?>" width="<?= $child->resize_width ?>" /><br />
<? else: ?>
<a href="<?= url::abs_site("{$child->type}s/{$child->id}") ?>">
<img alt="" src="<?= $child->thumb_url(true) ?>"
title="<?= p::clean($child->title) ?>"
title="<?= SafeString::of($child->title) ?>"
height="<?= $child->thumb_height ?>" width="<?= $child->thumb_width ?>" /></a><br />
<? endif ?>
<?= p::clean($child->description) ?>
<?= SafeString::of($child->description) ?>
</p>
]]>
</content:encoded>
+5 -5
View File
@@ -8,10 +8,10 @@
<ul>
<li>
<label for="q"><?= t("Search the gallery") ?></label>
<input name="q" id="q" type="text" value="<?= p::clean($q) ?>"/>
<input name="q" id="q" type="text" value="<?= SafeString::of($q)->for_html_attr() ?>"/>
</li>
<li>
<input type="submit" value="<?= t("Search") ?>" />
<input type="submit" value="<?= t("Search")->for_html_attr() ?>" />
</li>
</ul>
</fieldset>
@@ -31,10 +31,10 @@
<a href="<?= url::site("items/$item->id") ?>">
<?= $item->thumb_img() ?>
<p>
<?= p::purify($item->title) ?>
<?= SafeString::purify($item->title) ?>
</p>
<div>
<?= nl2br(p::purify($item->description)) ?>
<?= nl2br(SafeString::purify($item->description)) ?>
</div>
</a>
</li>
@@ -44,7 +44,7 @@
<? else: ?>
<p>
<?= t("No results found for <b>%term</b>", array("term" => p::clean($q))) ?>
<?= t("No results found for <b>%term</b>", array("term" => $q)) ?>
</p>
<? endif; ?>
@@ -38,7 +38,7 @@ class Admin_Server_Add_Controller extends Admin_Controller {
$path = $form->add_path->path->value;
$paths[$path] = 1;
module::set_var("server_add", "authorized_paths", serialize($paths));
message::success(t("Added path %path", array("path" => p::clean($path))));
message::success(t("Added path %path", array("path" => $path)));
server_add::check_config($paths);
url::redirect("admin/server_add");
} else {
@@ -60,7 +60,7 @@ class Admin_Server_Add_Controller extends Admin_Controller {
$paths = unserialize(module::get_var("server_add", "authorized_paths"));
if (isset($paths[$path])) {
unset($paths[$path]);
message::success(t("Removed path %path", array("path" => p::clean($path))));
message::success(t("Removed path %path", array("path" => $path)));
module::set_var("server_add", "authorized_paths", serialize($paths));
server_add::check_config($paths);
}
@@ -24,7 +24,7 @@
<? endif ?>
file="<?= $file ?>"
>
<?= p::clean(basename($file)) ?>
<?= SafeString::of(basename($file)) ?>
</span>
</li>
<? endforeach ?>
@@ -5,17 +5,17 @@
</script>
<div id="gServerAdd">
<h1 style="display: none;"><?= t("Add Photos to '%title'", array("title" => p::purify($item->title))) ?></h1>
<h1 style="display: none;"><?= t("Add Photos to '%title'", array("title" => SafeString::purify($item->title))) ?></h1>
<p id="gDescription"><?= t("Photos will be added to album:") ?></p>
<ul class="gBreadcrumbs">
<? foreach ($item->parents() as $parent): ?>
<li>
<?= p::purify($parent->title) ?>
<?= SafeString::purify($parent->title) ?>
</li>
<? endforeach ?>
<li class="active">
<?= p::purify($item->title) ?>
<?= SafeString::purify($item->title) ?>
</li>
</ul>
+4 -4
View File
@@ -53,8 +53,8 @@ class Admin_Tags_Controller extends Admin_Controller {
$name = $tag->name;
Database::instance()->delete("items_tags", array("tag_id" => "$tag->id"));
$tag->delete();
message::success(t("Deleted tag %tag_name", array("tag_name" => p::clean($name))));
log::success("tags", t("Deleted tag %tag_name", array("tag_name" => p::clean($name))));
message::success(t("Deleted tag %tag_name", array("tag_name" => $name)));
log::success("tags", t("Deleted tag %tag_name", array("tag_name" => $name)));
print json_encode(
array("result" => "success",
@@ -98,7 +98,7 @@ class Admin_Tags_Controller extends Admin_Controller {
$tag->save();
$message = t("Renamed tag %old_name to %new_name",
array("old_name" => p::clean($old_name), "new_name" => p::clean($tag->name)));
array("old_name" => $old_name, "new_name" => $tag->name));
message::success($message);
log::success("tags", $message);
@@ -106,7 +106,7 @@ class Admin_Tags_Controller extends Admin_Controller {
array("result" => "success",
"location" => url::site("admin/tags"),
"tag_id" => $tag->id,
"new_tagname" => p::clean($tag->name)));
"new_tagname" => SafeString::of($tag->name)));
} else {
print json_encode(
array("result" => "error",
+1 -1
View File
@@ -22,7 +22,7 @@ class tag_rss_Core {
static function available_feeds($item, $tag) {
if ($tag) {
$feeds["tag/tag/{$tag->id}"] =
t("Tag feed for %tag_name", array("tag_name" => p::clean($tag->name)));
t("Tag feed for %tag_name", array("tag_name" => $tag->name));
return $feeds;
}
return array();
+1 -1
View File
@@ -47,7 +47,7 @@
<? endif ?>
<li>
<span id="gTag-<?= $tag->id ?>" class="gEditable tag-name"><?= p::clean($tag->name) ?></span>
<span id="gTag-<?= $tag->id ?>" class="gEditable tag-name"><?= SafeString::of($tag->name) ?></span>
<span class="understate">(<?= $tag->count ?>)</span>
<a href="<?= url::site("admin/tags/form_delete/$tag->id") ?>"
class="gDialogLink delete-link gButtonLink">
+1 -1
View File
@@ -3,7 +3,7 @@
<? foreach ($tags as $tag): ?>
<li class="size<?=(int)(($tag->count / $max_count) * 7) ?>">
<span><?= $tag->count ?> photos are tagged with </span>
<a href="<?= url::site("tags/$tag->id") ?>"><?= p::clean($tag->name) ?></a>
<a href="<?= url::site("tags/$tag->id") ?>"><?= SafeString::of($tag->name) ?></a>
</li>
<? endforeach ?>
</ul>
+7 -7
View File
@@ -51,7 +51,7 @@ class Admin_Users_Controller extends Controller {
$user->save();
module::event("user_add_form_admin_completed", $user, $form);
message::success(t("Created user %user_name", array("user_name" => p::clean($user->name))));
message::success(t("Created user %user_name", array("user_name" => $user->name)));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error",
@@ -84,7 +84,7 @@ class Admin_Users_Controller extends Controller {
"form" => $form->__toString()));
}
$message = t("Deleted user %user_name", array("user_name" => p::clean($name)));
$message = t("Deleted user %user_name", array("user_name" => $name));
log::success("user", $message);
message::success($message);
print json_encode(array("result" => "success"));
@@ -142,7 +142,7 @@ class Admin_Users_Controller extends Controller {
$user->save();
module::event("user_edit_form_admin_completed", $user, $form);
message::success(t("Changed user %user_name", array("user_name" => p::clean($user->name))));
message::success(t("Changed user %user_name", array("user_name" => $user->name)));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error",
@@ -204,7 +204,7 @@ class Admin_Users_Controller extends Controller {
$group = group::create($new_name);
$group->save();
message::success(
t("Created group %group_name", array("group_name" => p::clean($group->name))));
t("Created group %group_name", array("group_name" => $group->name)));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error",
@@ -233,7 +233,7 @@ class Admin_Users_Controller extends Controller {
"form" => $form->__toString()));
}
$message = t("Deleted group %group_name", array("group_name" => p::clean($name)));
$message = t("Deleted group %group_name", array("group_name" => $name));
log::success("group", $message);
message::success($message);
print json_encode(array("result" => "success"));
@@ -271,11 +271,11 @@ class Admin_Users_Controller extends Controller {
$group->name = $form->edit_group->inputs["name"]->value;
$group->save();
message::success(
t("Changed group %group_name", array("group_name" => p::clean($group->name))));
t("Changed group %group_name", array("group_name" => $group->name)));
print json_encode(array("result" => "success"));
} else {
message::error(
t("Failed to change group %group_name", array("group_name" => p::clean($group->name))));
t("Failed to change group %group_name", array("group_name" => $group->name)));
print json_encode(array("result" => "error",
"form" => $form->__toString()));
}
+2 -2
View File
@@ -63,7 +63,7 @@ class Login_Controller extends Controller {
log::warning(
"user",
t("Failed login for %name",
array("name" => p::clean($form->login->inputs["name"]->value))));
array("name" => $form->login->inputs["name"]->value)));
$form->login->inputs["name"]->add_error("invalid_login", 1);
$valid = false;
}
@@ -71,7 +71,7 @@ class Login_Controller extends Controller {
if ($valid) {
user::login($user);
log::info("user", t("User %name logged in", array("name" => p::clean($user->name))));
log::info("user", t("User %name logged in", array("name" => $user->name)));
}
// Either way, regenerate the session id to avoid session trapping
+2 -2
View File
@@ -23,8 +23,8 @@ class Logout_Controller extends Controller {
$user = user::active();
user::logout();
log::info("user", t("User %name logged out", array("name" => p::clean($user->name))),
html::anchor("user/$user->id", p::clean($user->name)));
log::info("user", t("User %name logged out", array("name" => $user->name)),
html::anchor("user/$user->id", SafeString::of($user->name)));
if ($continue_url = $this->input->get("continue")) {
$item = url::get_item_from_uri($continue_url);
if (access::can("view", $item)) {
+1 -1
View File
@@ -74,7 +74,7 @@ class Password_Controller extends Controller {
log::success(
"user",
t("Password reset email sent for user %name", array("name" => p::clean($user->name))));
t("Password reset email sent for user %name", array("name" => $user->name)));
} else {
// Don't include the username here until you're sure that it's XSS safe
log::warning(
+4 -4
View File
@@ -68,16 +68,16 @@
<td id="user-<?= $user->id ?>" class="core-info gDraggable">
<img src="<?= $user->avatar_url(20, $theme->url("images/avatar.jpg", true)) ?>"
title="<?= t("Drag user onto group below to add as a new member") ?>"
alt="<?= p::clean($user->name) ?>"
alt="<?= SafeString::of($user->name) ?>"
width="20"
height="20" />
<?= p::clean($user->name) ?>
<?= SafeString::of($user->name) ?>
</td>
<td>
<?= p::clean($user->full_name) ?>
<?= SafeString::of($user->full_name) ?>
</td>
<td>
<?= p::clean($user->email) ?>
<?= SafeString::of($user->email) ?>
</td>
<td>
<?= ($user->last_login == 0) ? "" : gallery::date($user->last_login) ?>
@@ -1,9 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<h4>
<?= p::clean($group->name) ?>
<?= SafeString::of($group->name) ?>
<? if (!$group->special): ?>
<a href="<?= url::site("admin/users/delete_group_form/$group->id") ?>"
title="<?= t("Delete the %name group", array("name" => p::clean($group->name))) ?>"
title="<?= t("Delete the %name group", array("name" => $group->name)) ?>"
class="gDialogLink gButtonLink ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-trash"><?= t("delete") ?></span></a>
<? else: ?>
@@ -17,12 +17,12 @@
<ul>
<? foreach ($group->users as $i => $user): ?>
<li class="gUser">
<?= p::clean($user->name) ?>
<?= SafeString::of($user->name) ?>
<? if (!$group->special): ?>
<a href="javascript:remove_user(<?= $user->id ?>, <?= $group->id ?>)"
class="gButtonLink ui-state-default ui-corner-all ui-icon-left"
title="<?= t("Remove %user from %group group",
array("user" => p::clean($user->name), "group" => p::clean($group->name))) ?>">
array("user" => $user->name, "group" => $group->name)) ?>">
<span class="ui-icon ui-icon-closethick"><?= t("remove") ?></span>
</a>
<? endif ?>
+3 -3
View File
@@ -8,11 +8,11 @@
</li>
<? else: ?>
<li class="first">
<?= t('Logged in as %name', array('name' => SafeString::of(
<?= t('Logged in as %name', array('name' => SafeString::of_safe_html(
'<a href="' . url::site("form/edit/users/{$user->id}") .
'" title="' . t("Edit Your Profile") .
'" title="' . t("Edit Your Profile")->for_html_attr() .
'" id="gUserProfileLink" class="gDialogLink">' .
p::clean($user->display_name()) . '</a>')->mark_html_safe())) ?>
SafeString::of($user->display_name()) . '</a>'))) ?>
</li>
<li>
<a href="<?= url::site("logout?csrf=$csrf&amp;continue=" . urlencode(url::current(true))) ?>"
+1 -1
View File
@@ -6,7 +6,7 @@
<body>
<h2><?= t("Password Reset Request") ?> </h2>
<p>
<?= t("Hello, %name,", array("name" => p::clean($user->full_name ? $user->full_name : $user->name))) ?>
<?= t("Hello, %name,", array("name" => $user->full_name ? $user->full_name : $user->name)) ?>
</p>
<p>
<?= t("We received a request to reset your password for <a href=\"%site_url\">%site_url</a>. If you made this request, you can confirm it by <a href=\"%confirm_url\">clicking this link</a>. If you didn't request this password reset, it's ok to ignore this mail.", array("site_url" => url::base(false, "http"), "confirm_url" => $confirm_url)) ?>
+1 -1
View File
@@ -30,7 +30,7 @@ class request_Core {
// Set referrer
$ref = $_SERVER['HTTP_REFERER'];
if (strpos($ref, url::base(FALSE)) === 0)
if (strpos($ref, (string) url::base(FALSE)) === 0)
{
// Remove the base URL from the referrer
$ref = substr($ref, strlen(url::base(FALSE)));
+2 -2
View File
@@ -2,8 +2,8 @@
<? // @todo Set hover on AlbumGrid list items for guest users ?>
<div id="gInfo">
<?= $theme->album_top() ?>
<h1><?= SafeString::of($item->title)->purified_html() ?></h1>
<div class="gDescription"><?= nl2br(SafeString::of($item->description)->purified_html()) ?></div>
<h1><?= SafeString::purify($item->title) ?></h1>
<div class="gDescription"><?= nl2br(SafeString::purify($item->description)) ?></div>
</div>
<ul id="gAlbumGrid">
+2 -2
View File
@@ -3,7 +3,7 @@
<div id="gAlbumHeaderButtons">
<?= $theme->dynamic_top() ?>
</div>
<h1><?= p::clean($title) ?></h1>
<h1><?= SafeString::of($title) ?></h1>
</div>
<ul id="gAlbumGrid">
@@ -16,7 +16,7 @@
width="<?= $child->thumb_width ?>"
height="<?= $child->thumb_height ?>" />
</a>
<h2><?= p::purify($child->title) ?></h2>
<h2><?= SafeString::purify($child->title) ?></h2>
<?= $theme->thumb_bottom($child) ?>
<ul class="gMetadata">
<?= $theme->thumb_info($child) ?>
+2 -2
View File
@@ -19,10 +19,10 @@
<? foreach ($parents as $parent): ?>
<li>
<a href="<?= url::site("albums/{$parent->id}?show=$item->id") ?>">
<?= p::purify($parent->title) ?>
<?= SafeString::purify($parent->title) ?>
</a>
</li>
<? endforeach ?>
<li class="active"><?= p::purify($item->title) ?></li>
<li class="active"><?= SafeString::purify($item->title) ?></li>
</ul>
<? endif ?>
+2 -2
View File
@@ -15,8 +15,8 @@
<?= $item->movie_img(array("class" => "gMovie", "id" => "gMovieId-{$item->id}")) ?>
<div id="gInfo">
<h1><?= p::purify($item->title) ?></h1>
<div><?= nl2br(p::purify($item->description)) ?></div>
<h1><?= SafeString::purify($item->title) ?></h1>
<div><?= nl2br(SafeString::purify($item->description)) ?></div>
</div>
<script type="text/javascript">
+4 -4
View File
@@ -10,14 +10,14 @@
<? else: ?>
<? if ($theme->item()): ?>
<? if ($theme->item()->is_album()): ?>
<?= t("Browse Album :: %album_title", array("album_title" => p::clean($theme->item()->title))) ?>
<?= t("Browse Album :: %album_title", array("album_title" => $theme->item()->title)) ?>
<? elseif ($theme->item()->is_photo()): ?>
<?= t("Photo :: %photo_title", array("photo_title" => p::clean($theme->item()->title))) ?>
<?= t("Photo :: %photo_title", array("photo_title" => $theme->item()->title)) ?>
<? else: ?>
<?= t("Movie :: %movie_title", array("movie_title" => p::clean($theme->item()->title))) ?>
<?= t("Movie :: %movie_title", array("movie_title" => $theme->item()->title)) ?>
<? endif ?>
<? elseif ($theme->tag()): ?>
<?= t("Browse Tag :: %tag_title", array("tag_title" => p::clean($theme->tag()->name))) ?>
<?= t("Browse Tag :: %tag_title", array("tag_title" => $theme->tag()->name)) ?>
<? else: /* Not an item, not a tag, no page_title specified. Help! */ ?>
<?= t("Gallery") ?>
<? endif ?>
+2 -2
View File
@@ -50,8 +50,8 @@
</div>
<div id="gInfo">
<h1><?= p::purify($item->title) ?></h1>
<div><?= nl2br(p::purify($item->description)) ?></div>
<h1><?= SafeString::purify($item->title) ?></h1>
<div><?= nl2br(SafeString::purify($item->description)) ?></div>
</div>
<script type="text/javascript">