From 608b923a384298be20caae4ed22c0364db0f67f6 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sun, 1 Nov 2009 19:49:24 +0000 Subject: Bug 525025: Custom field names having UTF8-characters in them crash Bugzilla - Patch by Frédéric Buclin r/a=mkanat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Install/DB.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Bugzilla/Install') 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__ -- cgit v1.2.3-24-g4f1b