Closed Bug 27309 Opened 25 years ago Closed 23 years ago

SplitEnumType should handle apostrophe in enum value for Bugzilla parameter values


(Bugzilla :: Bugzilla-General, enhancement, P2)






(Reporter: randall.whitman, Assigned: justdave)



(1 file)

As stated in the comments above SplitEnumType in
"Assumes that enums don't ever contain an apostrophe!".
This is due to the following line in sub SplitEnumType:
        while ($guts =~ /^\'([^\']*)\',(.*)$/) {

At our site, we tried to use "Won't Fix" rather than "WONTFIX"
when we customized the Resolution values.

While customization of resolutions may be considered not supported by
Bugzilla, customization of severities, platforms, OSs, and priorities
definitely are supported.  These are also enum types, and SplitEnumType
is used on all of them.  It is not at all far-fetched that someone
would want a severity such as "Can't Run" or "Won't Run".

We worked around the problem by avoiding the apostrophe, but I submit
the following regexp for consideration, to force parsing up to the
next occurence of "',", rather than stopping at an apostrophe in the
middle of a value (not immediately followed by a comma):

I have unit-tested it on the following strings:

my @testcases;
push @testcases, qq{enum('','Fixed','Invalid','Won''t Fix','Future Version','Remind','Duplicate','Cannot Reproduce')};
push @testcases, qq{enum('','Fixed','Invalid','Won''t Fix','Good, Bad, Ugly','Remind','Duplicate','Cannot Reproduce')};
push @testcases, qq{enum('Cannot Reproduce')};

However, the above is not sufficient, due to MySQL quoting conventions, where
an apostrophe is expressed as a double apostrophe in the output of "desc"
(see attachment: demo of apostrophe in enum value).  The extra apostrophe
can be handled by changing the loop in SplitEnumType to the following.
I have unit-tested it successfully on the test strings listed above.

        while ($guts =~ /^\'(.*?)\',(.*)$/)
            $guts = $2;
            (my $temp = $1) =~ s/''/'/;
            push @result, $temp;

An alternate patch is to rewrite SplitEnumType using split().
I have unit-tested this successfully on the test strings listed above.

sub SplitEnumType
    my ($str) = (@_);
    my @result = ();
    if ($str =~ /^enum\('(.*)'\)$/)
        $str = $1;
        @result = split(/','/, $str);
        for my $index ($[..$#result)
            $result[$index] =~ s/''/'/;
    return @result;

We acknowledge a question of whether it is desirable to add extra code
for a special case, which may and may not be considered to be supported.
But if apostrophes are to be officially not supported, then this should
be documented in an appropriate place, namely the README and/or
comments in localconfig.

Note:  the issue of whether using enums in Bugzilla is a good idea at all
is discussed in bug #17453. is the new owner of Bugzilla and Bonsai.  (For details,
see my posting in netscape.public.mozilla.webtools,
news:// .)
Assignee: terry → tara
enums are going away with a new schema. evaluate for 2.12
Assignee: tara → cyeh
Whiteboard: 2.12
dropping 2.12 from whiteboard. i put an annotation in so that if 
someone were to go tweak the enum values, there's a comment there that we don't 
support it.

enums are the first thing to go away after 2.12, so i'm going to leave this bug 
as open and assigned until they are gone.
Whiteboard: 2.12
QA Contact: matty
Whiteboard: 2.14
Whiteboard: 2.14 → 2.16
moving to real milestones...
Target Milestone: --- → Bugzilla 2.16
Depends on: bz-enums
Whiteboard: 2.16
Priority: P3 → P2
Taking all of cyeh's Bugzilla bugs.
Assignee: Chris.Yeh → justdave
Component: Bugzilla → Bugzilla-General
Product: Webtools → Bugzilla
Version: other → unspecified
Bug 17453 is going to negate the need for this by removing the enums, and thus
we'll have no need to split them anymore.
Closed: 23 years ago
No longer depends on: bz-enums
OS: Linux → All
Hardware: PC → All
Resolution: --- → WONTFIX
Target Milestone: Bugzilla 2.16 → ---
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.