Closed Bug 237591 Opened 20 years ago Closed 20 years ago

Regexp metachars in product names break importxml.pl

Categories

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

2.16.5
defect
Not set
major

Tracking

()

RESOLVED FIXED
Bugzilla 2.16

People

(Reporter: Richard.Giraud, Assigned: justdave)

Details

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

Attachments

(4 files)

User-Agent:       Opera/7.23 (Windows NT 5.0; U)  [en]
Build Identifier: 

importxml.pl does not properly import bugs.  Instead, it gives the following 
message:

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 importxml.pl on file (e.g., sudo perl importxml.pl 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, importxml.pl 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.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
OS: MacOS X → All
Hardware: Macintosh → All
Summary: can not import data via importxml.pl; problem with filtering arrays via grep. → Regexp metachars in product names break importxml.pl
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 importxml.pl;
/cvsroot/mozilla/webtools/bugzilla/importxml.pl,v  <--  importxml.pl
new revision: 1.23.2.3; previous revision: 1.23.2.2
done
Status: ASSIGNED → RESOLVED
Closed: 20 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.

Attachment

General

Creator:
Created:
Updated:
Size: