Closed Bug 237591 Opened 17 years ago Closed 17 years ago

Regexp metachars in product names break


(Bugzilla :: Bug Import/Export & Moving, defect)

Not set



Bugzilla 2.16


(Reporter: Richard.Giraud, Assigned: justdave)


(Whiteboard: [fixed in 2.16.6] [does not affect trunk])


(4 files)

User-Agent:       Opera/7.23 (Windows NT 5.0; U)  [en]
Build Identifier: does not properly import bugs.  Instead, it gives the following 

Bug import error: invalid default product or component

Reproducible: Always
Steps to Reproduce:
1. Create XML representation of a bug via xml.cgi
2. Save to disk.
3. Run on file (e.g., sudo perl bug.xml).

Actual Results:  
Import stopped during first bug with following message.

Bug import error: invalid default product or component

Expected Results:  
Imported the bug.

Around line 380 or so, filters the arrays of products and 
components using the grep command.  An examination reveals that grep filters out 
all elements in the array.

The product name is correctly determined a few lines earlier and a comparison of 
the product name to the first element of the @::legal_product array returns a 
value of 1.

Similar problems occur with the component checking.

The version of PERL being used is v5.8.1-RC3.

I will include example code shortly (it is on a different box).
What version of Bugzilla?

There is no "grep" in use in the current version leading up to the mentioned
error message.  It's just calling get_product_id() on it and giving the error if
that fails.
This is the minimal dataset that I have tested that causes the problem.
OK, found the code in question in 2.16.5.

Someone wrote some really sloppy grep code there.  No quoting of the variables,
and your product names have regexp metachars in them.

Adding \Q and \E around the variable names will probably fix it, but doing
{ lc($_) eq lc($product_name) } in place of the regexp would probably be a much
better fix.
Ever confirmed: true
OS: MacOS X → All
Hardware: Macintosh → All
Summary: can not import data via; problem with filtering arrays via grep. → Regexp metachars in product names break
Whiteboard: [wanted for 2.16.6] [does not affect trunk]
Target Milestone: --- → Bugzilla 2.16
Version: unspecified → 2.16.5
I have added some print statements to display the internal state of the script
at the appropriate points.
Attached patch Patch v1Splinter Review
Give this patch a shot and let me know if this fixes it.
Attachment #143999 - Flags: review?(bbaetz)
Attachment #143999 - Flags: review?(guzman)
That solved the problem.  Thank you very much :)
Attachment #143999 - Flags: review?(bbaetz) → review+
Flags: blocking2.16.6+
Checking in;
/cvsroot/mozilla/webtools/bugzilla/,v  <--
new revision:; previous revision:
Closed: 17 years ago
Flags: approval2.16+
Resolution: --- → FIXED
Whiteboard: [wanted for 2.16.6] [does not affect trunk] → [fixed in 2.16.6] [does not affect trunk]
Comment on attachment 143999 [details] [diff] [review]
Patch v1

Removing r? from FIXED bug.
Attachment #143999 - Flags: review?(guzman)
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.