diff options
author | lpsolit%gmail.com <> | 2009-11-01 19:49:24 +0000 |
---|---|---|
committer | lpsolit%gmail.com <> | 2009-11-01 19:49:24 +0000 |
commit | 608b923a384298be20caae4ed22c0364db0f67f6 (patch) | |
tree | ef1314605fe3911763071787a5231cd00976f83a /Bugzilla | |
parent | 86e901444f9b940291014c77a00829a32be799b9 (diff) | |
download | bugs-608b923a384298be20caae4ed22c0364db0f67f6.tar bugs-608b923a384298be20caae4ed22c0364db0f67f6.tar.gz bugs-608b923a384298be20caae4ed22c0364db0f67f6.tar.bz2 bugs-608b923a384298be20caae4ed22c0364db0f67f6.tar.xz bugs-608b923a384298be20caae4ed22c0364db0f67f6.zip |
Bug 525025: Custom field names having UTF8-characters in them crash Bugzilla - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Field.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Install/DB.pm | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 077c67e20..7b1569c52 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -273,7 +273,7 @@ sub _check_name { my $name_regex = qr/^[\w\.]+$/; # Custom fields have more restrictive name requirements than # standard fields. - $name_regex = qr/^\w+$/ if $is_custom; + $name_regex = qr/^[a-zA-Z0-9_]+$/ if $is_custom; # Custom fields can't be named just "cf_", and there is no normal # field named just "cf_". ($name =~ $name_regex && $name ne "cf_") diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index df6296056..51d258227 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -583,6 +583,9 @@ sub update_table_definitions { # 2009-09-28 LpSolit@gmail.com - Bug 399073 _fix_logincookies_ipaddr(); + # 2009-11-01 LpSolit@gmail.com - Bug 525025 + _fix_invalid_custom_field_names(); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ @@ -3219,6 +3222,19 @@ sub _fix_logincookies_ipaddr { undef, '0.0.0.0'); } +sub _fix_invalid_custom_field_names { + my @fields = Bugzilla->get_fields({ custom => 1 }); + + foreach my $field (@fields) { + next if $field->name =~ /^[a-zA-Z0-9_]+$/; + # The field name is illegal and can break the DB. Kill the field! + $field->set_obsolete(1); + eval { $field->remove_from_db(); }; + print "Removing custom field '" . $field->name . "' (illegal name)... "; + print $@ ? "failed\n$@\n" : "succeeded\n"; + } +} + 1; __END__ |