Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
c6c54c2e
Commit
c6c54c2e
authored
Aug 18, 2012
by
Koosha Khajeh Moogahi
Committed by
Frédéric Buclin
Aug 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 187753: Specify a maximum length for quips (512 characters)
r/a=LpSolit
parent
ca3d5907
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
4 deletions
+39
-4
Constants.pm
Bugzilla/Constants.pm
+4
-0
Schema.pm
Bugzilla/DB/Schema.pm
+1
-1
DB.pm
Bugzilla/Install/DB.pm
+23
-2
quips.cgi
quips.cgi
+4
-0
user-error.html.tmpl
template/en/default/global/user-error.html.tmpl
+6
-0
quips.html.tmpl
template/en/default/list/quips.html.tmpl
+1
-1
No files found.
Bugzilla/Constants.pm
View file @
c6c54c2e
...
...
@@ -161,6 +161,7 @@ use Memoize;
MAX_BUG_URL_LENGTH
MAX_POSSIBLE_DUPLICATES
MAX_ATTACH_FILENAME_LENGTH
MAX_QUIP_LENGTH
PASSWORD_DIGEST_ALGORITHM
PASSWORD_SALT_LENGTH
...
...
@@ -556,6 +557,9 @@ use constant MAX_POSSIBLE_DUPLICATES => 25;
# necessary schema changes to store longer names.
use
constant
MAX_ATTACH_FILENAME_LENGTH
=>
255
;
# Maximum length of a quip.
use
constant
MAX_QUIP_LENGTH
=>
512
;
# This is the name of the algorithm used to hash passwords before storing
# them in the database. This can be any string that is valid to pass to
# Perl's "Digest" module. Note that if you change this, it won't take
...
...
Bugzilla/DB/Schema.pm
View file @
c6c54c2e
...
...
@@ -1484,7 +1484,7 @@ use constant ABSTRACT_SCHEMA => {
REFERENCES
=>
{
TABLE
=>
'profiles'
,
COLUMN
=>
'userid'
,
DELETE
=>
'SET NULL'
}},
quip
=>
{
TYPE
=>
'
MEDIUMTEXT
'
,
NOTNULL
=>
1
},
quip
=>
{
TYPE
=>
'
varchar(512)
'
,
NOTNULL
=>
1
},
approved
=>
{
TYPE
=>
'BOOLEAN'
,
NOTNULL
=>
1
,
DEFAULT
=>
'TRUE'
},
],
...
...
Bugzilla/Install/DB.pm
View file @
c6c54c2e
...
...
@@ -697,6 +697,9 @@ sub update_table_definitions {
# 2012-08-02 dkl@mozilla.com - Bug 756953
_fix_dependencies_dupes
();
# 2012-08-01 koosha.khajeh@gmail.com - Bug 187753
_shorten_long_quips
();
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
...
...
@@ -3164,8 +3167,6 @@ sub _change_text_types {
{
TYPE
=>
'TINYTEXT'
,
NOTNULL
=>
1
});
$dbh
->
bz_alter_column
(
'groups'
,
'description'
,
{
TYPE
=>
'MEDIUMTEXT'
,
NOTNULL
=>
1
});
$dbh
->
bz_alter_column
(
'quips'
,
'quip'
,
{
TYPE
=>
'MEDIUMTEXT'
,
NOTNULL
=>
1
});
$dbh
->
bz_alter_column
(
'namedqueries'
,
'query'
,
{
TYPE
=>
'LONGTEXT'
,
NOTNULL
=>
1
});
...
...
@@ -3753,6 +3754,26 @@ sub _fix_dependencies_dupes {
}
}
sub
_shorten_long_quips
{
my
$dbh
=
Bugzilla
->
dbh
;
my
$quips
=
$dbh
->
selectall_arrayref
(
"SELECT quipid, quip FROM quips
WHERE CHAR_LENGTH(quip) > 512"
);
if
(
@$quips
)
{
print
"Shortening quips longer than 512 characters:"
;
my
$query
=
$dbh
->
prepare
(
"UPDATE quips SET quip = ? WHERE quipid = ?"
);
foreach
my
$quip
(
@$quips
)
{
my
(
$quipid
,
$quip_str
)
=
@$quip
;
$quip_str
=
substr
(
$quip_str
,
0
,
509
)
.
"..."
;
print
" $quipid"
;
$query
->
execute
(
$quip_str
,
$quipid
);
}
}
$dbh
->
bz_alter_column
(
'quips'
,
'quip'
,
{
TYPE
=>
'varchar(512)'
,
NOTNULL
=>
1
});
}
1
;
__END__
...
...
quips.cgi
View file @
c6c54c2e
...
...
@@ -65,6 +65,10 @@ if ($action eq "add") {
||
$user
->
in_group
(
'bz_quip_moderators'
)
||
0
;
my
$comment
=
$cgi
->
param
(
"quip"
);
$comment
||
ThrowUserError
(
"need_quip"
);
ThrowUserError
(
"quip_too_long"
,
{
length
=>
length
(
$comment
)
})
if
length
(
$comment
)
>
MAX_QUIP_LENGTH
;
trick_taint
(
$comment
);
# Used in a placeholder below
$dbh
->
do
(
"INSERT INTO quips (userid, quip, approved) VALUES (?, ?, ?)"
,
...
...
template/en/default/global/user-error.html.tmpl
View file @
c6c54c2e
...
...
@@ -1479,6 +1479,12 @@
<a href="page.cgi?id=quicksearch.html#fields">listed here</a>.</p>
[% END %]
[% ELSIF error == "quip_too_long" %]
[% title = "Quip Too Long" %]
You entered a quip with a length of [% length FILTER none %] characters,
but the maximum allowed length is [% constants.MAX_QUIP_LENGTH FILTER none %]
characters.
[% ELSIF error == "reassign_to_empty" %]
[% title = "Illegal Reassignment" %]
To reassign [% terms.abug %], you must provide an address for
...
...
template/en/default/list/quips.html.tmpl
View file @
c6c54c2e
...
...
@@ -61,7 +61,7 @@
<input type="hidden" name="action" value="add">
<input type="hidden" name="token"
value="[% issue_hash_token(['create-quips']) FILTER html %]">
<input size="80" name="quip">
<input size="80" name="quip"
maxlength="512"
>
<p>
<input type="submit" id="add" value="Add This Quip">
</p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment