Bug 868330 - Password creation directions incomplete

r=sgreen, a=sgreen


git-svn-id: svn://10.0.0.236/trunk@264957 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzrmirror%bugzilla.org 2013-08-13 18:47:50 +00:00
parent 3a5d0be0fe
commit c9f2d293ab
21 changed files with 66 additions and 189 deletions

View File

@ -1 +1 @@
8699
8689

View File

@ -126,7 +126,8 @@ the ID of the bug to which the attachment is attached
=cut
sub bug_id {
return $_[0]->{bug_id};
my $self = shift;
return $self->{bug_id};
}
=over
@ -140,8 +141,11 @@ the bug object to which the attachment is attached
=cut
sub bug {
my $self = shift;
require Bugzilla::Bug;
return $_[0]->{bug} //= Bugzilla::Bug->new({ id => $_[0]->bug_id, cache => 1 });
$self->{bug} ||= Bugzilla::Bug->new({ id => $self->bug_id, cache => 1 });
return $self->{bug};
}
=over
@ -155,7 +159,8 @@ user-provided text describing the attachment
=cut
sub description {
return $_[0]->{description};
my $self = shift;
return $self->{description};
}
=over
@ -169,7 +174,8 @@ the attachment's MIME media type
=cut
sub contenttype {
return $_[0]->{mimetype};
my $self = shift;
return $self->{mimetype};
}
=over
@ -183,8 +189,9 @@ the user who attached the attachment
=cut
sub attacher {
return $_[0]->{attacher}
//= new Bugzilla::User({ id => $_[0]->{submitter_id}, cache => 1 });
my $self = shift;
return $self->{attacher}
||= new Bugzilla::User({ id => $self->{submitter_id}, cache => 1 });
}
=over
@ -198,7 +205,8 @@ the date and time on which the attacher attached the attachment
=cut
sub attached {
return $_[0]->{creation_ts};
my $self = shift;
return $self->{creation_ts};
}
=over
@ -212,7 +220,8 @@ the date and time on which the attachment was last modified.
=cut
sub modification_time {
return $_[0]->{modification_time};
my $self = shift;
return $self->{modification_time};
}
=over
@ -226,7 +235,8 @@ the name of the file the attacher attached
=cut
sub filename {
return $_[0]->{filename};
my $self = shift;
return $self->{filename};
}
=over
@ -240,7 +250,8 @@ whether or not the attachment is a patch
=cut
sub ispatch {
return $_[0]->{ispatch};
my $self = shift;
return $self->{ispatch};
}
=over
@ -254,7 +265,8 @@ whether or not the attachment is obsolete
=cut
sub isobsolete {
return $_[0]->{isobsolete};
my $self = shift;
return $self->{isobsolete};
}
=over
@ -268,7 +280,8 @@ whether or not the attachment is private
=cut
sub isprivate {
return $_[0]->{isprivate};
my $self = shift;
return $self->{isprivate};
}
=over
@ -285,7 +298,8 @@ matches, because this will return a value even if it's matched by the generic
=cut
sub is_viewable {
my $contenttype = $_[0]->contenttype;
my $self = shift;
my $contenttype = $self->contenttype;
my $cgi = Bugzilla->cgi;
# We assume we can view all text and image types.
@ -359,7 +373,7 @@ the length (in bytes) of the attachment content
sub datasize {
my $self = shift;
return $self->{datasize} if defined $self->{datasize};
return $self->{datasize} if exists $self->{datasize};
# If we have already retrieved the data, return its size.
return length($self->{data}) if exists $self->{data};
@ -402,8 +416,11 @@ flags that have been set on the attachment
=cut
sub flags {
my $self = shift;
# Don't cache it as it must be in sync with ->flag_types.
return $_[0]->{flags} = [map { @{$_->{flags}} } @{$_[0]->flag_types}];
$self->{flags} = [map { @{$_->{flags}} } @{$self->flag_types}];
return $self->{flags};
}
=over
@ -426,7 +443,8 @@ sub flag_types {
component_id => $self->bug->component_id,
attach_id => $self->id };
return $self->{flag_types} = Bugzilla::Flag->_flag_types($vars);
$self->{flag_types} = Bugzilla::Flag->_flag_types($vars);
return $self->{flag_types};
}
###############################
@ -659,7 +677,7 @@ sub get_attachments_by_bug {
# To avoid $attachment->flags to run SQL queries itself for each
# attachment listed here, we collect all the data at once and
# populate $attachment->{flags} ourselves.
# We also load all attachers and datasizes at once for the same reason.
# We also load all attachers at once for the same reason.
if ($vars->{preload}) {
# Preload flags.
$_->{flags} = [] foreach @$attachments;
@ -681,16 +699,6 @@ sub get_attachments_by_bug {
foreach my $attachment (@$attachments) {
$attachment->{attacher} = $user_map{$attachment->{submitter_id}};
}
# Preload datasizes.
my $sizes =
$dbh->selectall_hashref('SELECT attach_id, LENGTH(thedata) AS size
FROM attachments LEFT JOIN attach_data ON attach_id = id
WHERE bug_id = ?',
'attach_id', undef, $bug->id);
# Force the size of attachments not in the DB to be recalculated.
$_->{datasize} = $sizes->{$_->id}->{size} || undef foreach @$attachments;
}
return $attachments;
}

View File

@ -236,11 +236,11 @@ sub check_etag {
$possible_etag =~ s/^\"//g;
$possible_etag =~ s/\"$//g;
if ($possible_etag eq $valid_etag or $possible_etag eq '*') {
return 1;
print $self->header(-ETag => $possible_etag,
-status => '304 Not Modified');
exit;
}
}
return 0;
}
# Have to add the cookies in.

View File

@ -87,8 +87,6 @@ sub SETTINGS {
requestee_cc => { options => ['on', 'off'], default => 'on' },
# 2012-04-30 glob@mozilla.com -- Bug 663747
bugmail_new_prefix => { options => ['on', 'off'], default => 'on' },
# 2013-07-26 joshi_sunil@in.com -- Bug 669535
possible_duplicates => { options => ['on', 'off'], default => 'on' },
}
};

View File

@ -825,7 +825,8 @@ sub in_group_id {
sub groups_with_icon {
my $self = shift;
return $self->{groups_with_icon} //= [grep { $_->icon_url } @{ $self->groups }];
my @groups = grep { $_->icon_url } @{ $self->groups };
return \@groups;
}
sub get_products_by_permission {

View File

@ -71,10 +71,7 @@ sub html_quote {
$var =~ s/"/"/g;
# Obscure '@'.
$var =~ s/\@/\@/g;
state $use_utf8 = Bugzilla->params->{'utf8'};
if ($use_utf8) {
if (Bugzilla->params->{'utf8'}) {
# Remove the following characters because they're
# influencing BiDi:
# --------------------------------------------------------
@ -96,7 +93,7 @@ sub html_quote {
# |U+200e|Left-To-Right Mark |0xe2 0x80 0x8e |
# |U+200f|Right-To-Left Mark |0xe2 0x80 0x8f |
# --------------------------------------------------------
$var =~ tr/\x{202a}-\x{202e}//d;
$var =~ s/[\x{202a}-\x{202e}]//g;
}
return $var;
}

View File

@ -349,18 +349,6 @@ sub get {
push(@bugs, $self->_bug_to_hash($bug, $params));
}
# Set the ETag before inserting the update tokens
# since the tokens will always be unique even if
# the data has not changed.
$self->bz_etag(\@bugs);
if (Bugzilla->user->id) {
foreach my $bug (@bugs) {
my $token = issue_hash_token([$bug->{'id'}, $bug->{'last_change_time'}]);
$bug->{'update_token'} = $self->type('string', $token);
}
}
return { bugs => \@bugs, faults => \@faults };
}
@ -998,6 +986,11 @@ sub _bug_to_hash {
}
}
if (Bugzilla->user->id) {
my $token = issue_hash_token([$bug->id, $bug->delta_ts]);
$item{'update_token'} = $self->type('string', $token);
}
# The "accessible" bits go here because they have long names and it
# makes the code look nicer to separate them out.
$item{'is_cc_accessible'} = $self->type('boolean',

View File

@ -14,9 +14,6 @@ use Bugzilla::Error;
use Bugzilla::Util qw(datetime_from);
use Scalar::Util qw(blessed);
use Digest::MD5 qw(md5_base64);
use Storable qw(freeze);
sub handle_login {
my ($self, $class, $method, $full_method) = @_;
@ -32,7 +29,7 @@ sub handle_login {
sub datetime_format_inbound {
my ($self, $time) = @_;
my $converted = datetime_from($time, Bugzilla->local_timezone);
if (!defined $converted) {
ThrowUserError('illegal_date', { date => $time });
@ -58,63 +55,8 @@ sub datetime_format_outbound {
return $time->iso8601();
}
# ETag support
sub bz_etag {
my ($self, $data) = @_;
my $cache = Bugzilla->request_cache;
if (defined $data) {
# Serialize the data if passed a reference
local $Storable::canonical = 1;
$data = freeze($data) if ref $data;
# Wide characters cause md5_base64() to die.
utf8::encode($data) if utf8::is_utf8($data);
# Append content_type to the end of the data
# string as we want the etag to be unique to
# the content_type. We do not need this for
# XMLRPC as text/xml is always returned.
if (blessed($self) && $self->can('content_type')) {
$data .= $self->content_type if $self->content_type;
}
$cache->{'bz_etag'} = md5_base64($data);
}
return $cache->{'bz_etag'};
}
1;
=head1 NAME
Bugzilla::WebService::Server - Base server class for the WebService API
=head1 DESCRIPTION
Bugzilla::WebService::Server is the base class for the individual WebService API
servers such as XMLRPC, JSONRPC, and REST. You never actually create a
Bugzilla::WebService::Server directly, you only make subclasses of it.
=head1 FUNCTIONS
=over
=item C<bz_etag>
This function is used to store an ETag value that will be used when returning
the data by the different API server modules such as XMLRPC, or REST. The individual
webservice methods can also set the value earlier in the process if needed such as
before a unique update token is added. If a value is not set earlier, an etag will
automatically be created using the returned data except in some cases when an error
has occurred.
=back
=head1 SEE ALSO
L<Bugzilla::WebService::Server::XMLRPC|XMLRPC>, L<Bugzilla::WebService::Server::JSONRPC|JSONRPC>,
and L<Bugzilla::WebService::Server::REST|REST>.
=head1 B<Methods in need of POD>
=over

View File

@ -75,12 +75,12 @@ sub response_header {
sub response {
my ($self, $response) = @_;
my $cgi = $self->cgi;
# Implement JSONP.
if (my $callback = $self->_bz_callback) {
my $content = $response->content;
$response->content("$callback($content)");
}
# Use $cgi->header properly instead of just printing text directly.
@ -95,18 +95,9 @@ sub response {
push(@header_args, "-$name", $value);
}
}
# ETag support
my $etag = $self->bz_etag;
if ($etag && $cgi->check_etag($etag)) {
push(@header_args, "-ETag", $etag);
print $cgi->header(-status => '304 Not Modified', @header_args);
}
else {
push(@header_args, "-ETag", $etag) if $etag;
print $cgi->header(-status => $response->code, @header_args);
print $response->content;
}
my $cgi = $self->cgi;
print $cgi->header(-status => $response->code, @header_args);
print $response->content;
}
# The JSON-RPC 1.1 GET specification is not so great--you can't specify
@ -266,17 +257,7 @@ sub _handle {
my $self = shift;
my ($obj) = @_;
$self->{_bz_request_id} = $obj->{id};
my $result = $self->SUPER::_handle(@_);
# Set the ETag if not already set in the webservice methods.
my $etag = $self->bz_etag;
if (!$etag && ref $result) {
my $data = $self->json->decode($result)->{'result'};
$self->bz_etag($data);
}
return $result;
return $self->SUPER::_handle(@_);
}
# Make all error messages returned by JSON::RPC go into the 100000

View File

@ -125,10 +125,6 @@ sub response {
# Access Control
$response->header("Access-Control-Allow-Origin", "*");
# ETag support
my $etag = $self->bz_etag;
$self->bz_etag($result) if !$etag;
# If accessing through web browser, then display in readable format
if ($self->content_type eq 'text/html') {
$result = $self->json->pretty->canonical->encode($result);

View File

@ -21,8 +21,8 @@ if ($ENV{MOD_PERL}) {
use Bugzilla::WebService::Constants;
use Bugzilla::Util;
# Allow WebService methods to call XMLRPC::Lite's type method directly
BEGIN {
# Allow WebService methods to call XMLRPC::Lite's type method directly
*Bugzilla::WebService::type = sub {
my ($self, $type, $value) = @_;
if ($type eq 'dateTime') {
@ -39,11 +39,6 @@ BEGIN {
}
return XMLRPC::Data->type($type)->value($value);
};
# Add support for ETags into XMLRPC WebServices
*Bugzilla::WebService::bz_etag = sub {
return Bugzilla::WebService::Server->bz_etag($_[1]);
};
}
sub initialize {
@ -57,38 +52,22 @@ sub initialize {
sub make_response {
my $self = shift;
my $cgi = Bugzilla->cgi;
$self->SUPER::make_response(@_);
# XMLRPC::Transport::HTTP::CGI doesn't know about Bugzilla carrying around
# its cookies in Bugzilla::CGI, so we need to copy them over.
foreach my $cookie (@{$cgi->{'Bugzilla_cookie_list'}}) {
foreach my $cookie (@{Bugzilla->cgi->{'Bugzilla_cookie_list'}}) {
$self->response->headers->push_header('Set-Cookie', $cookie);
}
# Copy across security related headers from Bugzilla::CGI
foreach my $header (split(/[\r\n]+/, $cgi->header)) {
foreach my $header (split(/[\r\n]+/, Bugzilla->cgi->header)) {
my ($name, $value) = $header =~ /^([^:]+): (.*)/;
if (!$self->response->headers->header($name)) {
$self->response->headers->header($name => $value);
}
}
# ETag support
my $etag = $self->bz_etag;
if (!$etag) {
my $data = $self->response->as_string;
$etag = $self->bz_etag($data);
}
if ($etag && $cgi->check_etag($etag)) {
$self->response->headers->push_header('ETag', $etag);
$self->response->headers->push_header('status', '304 Not Modified');
}
elsif ($etag) {
$self->response->headers->push_header('ETag', $etag);
}
}
sub handle_login {

View File

@ -105,7 +105,7 @@ my $serverpush =
&& exists $ENV{'HTTP_USER_AGENT'}
&& $ENV{'HTTP_USER_AGENT'} =~ /(Mozilla.[3-9]|Opera)/
&& $ENV{'HTTP_USER_AGENT'} !~ /compatible/i
&& $ENV{'HTTP_USER_AGENT'} !~ /(?:WebKit|Trident)/
&& $ENV{'HTTP_USER_AGENT'} !~ /WebKit/
&& !defined($cgi->param('serverpush'))
|| $cgi->param('serverpush');

View File

@ -142,11 +142,7 @@ sub display_data {
utf8::encode($digest_data) if utf8::is_utf8($digest_data);
my $digest = md5_base64($digest_data);
if ($cgi->check_etag($digest)) {
print $cgi->header(-ETag => $digest,
-status => '304 Not Modified');
exit;
}
$cgi->check_etag($digest);
print $cgi->header (-ETag => $digest,
-type => $format->{'ctype'});

View File

@ -1065,7 +1065,7 @@
<para>
<emphasis>Login Name</emphasis>:
This is generally the user's full email address. However, if you
are using the <quote>emailsuffix</quote> parameter, this may
have are using the <quote>emailsuffix</quote> parameter, this may
just be the user's login name. Note that users can now change their
login names themselves (to any valid email address).
</para>

View File

@ -20,9 +20,9 @@ use Bugzilla::DB::Schema;
# SQL reserved words
use constant RESERVED_WORDS => qw(
ABSOLUTE ACTION ACTOR ADD AFTER ALL ALLOCATE ALTER ANY AND ARE AS ASC ASSERTION ASYNC AT
ATTRIBUTES BEFORE BEGIN BETWEEN BIT BIT_LENGTH BOOLEAN BOTH BREADTH BY CALL CASCADE
CASCADED CASE CAST CATALOG CHAR CHARACTER_LENGTH CHAR_LENGTH COLLATE
ABSOLUTE ACTION ACTOR ADD AFTER ALL ALLOCATE ALTER ANY AND ARE ASC ASSERTION ASYNC AT
ATTRIBUTES BEFORE BEGIN BETWEEN BIT BIT_LENGTH BOOLEAN BOTH BREADTH CALL CASCADE
CASCADED CASE CAST CATALOG CHARACTER_LENGTH CHAR_LENGTH COLLATE
COLLATION COLUMN COMPLETION CONNECT CONNECTION CONSTRAINT CONSTRAINTS
CONVERT CORRESPONDING CREATE CROSS CURRENT_DATE CURRENT_PATH CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CYCLE DATA DATE DAY DEALLOCATE DECLARE DEFAULT DEFERRABLE
@ -42,7 +42,7 @@ use constant RESERVED_WORDS => qw(
SQLWARNING START STATE STRUCTURE SUBSTRING SYMBOL SYSTEM_USER TABLE TEMPORARY
TERM TEST THEN THERE TIME TIMESTAMP TIMEZONE_HOUR TIMEZONE_MINUTE TRAILING
TRANSACTION TRANSLATE TRANSLATION TRIGGER TRIM TRUE TUPLE UNDER
UNKNOWN UNION UNIQUE UPDATE UPPER USAGE USING VARCHAR VARIABLE VARYING VIEW VIRTUAL VISIBLE
UNKNOWN UNION UNIQUE UPDATE UPPER USAGE USING VARCHAR VARIABLE VARYING VIRTUAL VISIBLE
WAIT WHEN WHERE WHILE WITH WITHOUT WRITE YEAR ZONE
);

View File

@ -55,7 +55,6 @@
Share With a Group
</th>
[% END %]
[% Hook.process('saved-header') %]
</tr>
<tr>
<td>My [% terms.Bugs %]</td>
@ -80,7 +79,6 @@
&mdash;
</td>
[% END %]
[% Hook.process('saved-row') %]
</tr>
[% FOREACH q = user.queries %]
<tr>
@ -135,7 +133,6 @@
[% END %]
</td>
[% END %]
[% Hook.process('saved-row') %]
</tr>
[% END %]
</table>

View File

@ -491,8 +491,7 @@ TUI_hide_default('attachment_text_field');
</td>
</tr>
[% IF feature_enabled('jsonrpc') AND !cloned_bug_id
AND user.settings.possible_duplicates.value == 'on' %]
[% IF feature_enabled('jsonrpc') AND !cloned_bug_id %]
<tr id="possible_duplicates_container" class="bz_default_hidden">
<th>Possible<br>Duplicates:</th>
<td colspan="3">

View File

@ -76,10 +76,6 @@ estimated_time =>
"The amount of time that has been estimated it will take to resolve
this ${terms.bug}.",
importance =>
"The importance of $terms.abug is described as the combination of
its $vars.field_descs.priority and ${vars.field_descs.bug_severity}.",
keywords =>
"You can add keywords from a defined list to $terms.bugs, in order"
_ " to easily identify and group them.",

View File

@ -43,7 +43,6 @@
"text_only" => "Text Only",
"requestee_cc" => "Automatically add me to the CC list of $terms.bugs I am requested to review",
"bugmail_new_prefix" => "Add 'New:' to subject line of email sent when a new $terms.bug is filed",
"possible_duplicates" => "Display possible duplicates when reporting a new $terms.bug",
}
%]

View File

@ -181,11 +181,6 @@
field => field } %]
[% END %]
[%# This field is not a real one, but its label is visible in bugs. %]
[% field_help_map.Importance = { help => help_html.importance,
field => "importance" } %]
[%# These are fields that don't need to be documented, either because
# they have docs somewhere else in the UI, or they don't show up on bugs.
# %]

View File

@ -105,7 +105,7 @@
[% FOREACH current_value = legal_values %]
[% SET v = current_value.name OR '---' -%]
[% SET display = display_value(field.name, current_value.name) %]
<option value="[% v FILTER html %]"
<option [% IF v != display %]value="[% v FILTER html %]"[% END ~%]
id="v[% current_value.id FILTER html %]_[% field.name FILTER html %]"
[% ' selected="selected"' IF value.contains( v ) %]>
[%~ display FILTER html ~%]