lib File Corruption if Field Has Double Quote
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
KiCad |
Fix Released
|
Low
|
jean-pierre charras |
Bug Description
The .lib files, which contain parts used in the schematic editor, uses the double quote character (") as a delimiter to separate field value, field coordinates, and field label data. If, in the library editor, the fields are edited using the T icon at the top of the window, and a string containing a double quote character is copy and pasted into the value part of the field, the double quote character corrupts the lib file. It happens because a double quote character ends up in the wrong place for a delimiter.
After the editor opened by the T icon is closed by clicking on the OK button, the corruption manifests itself by Kicad crashing if the field is double clicked on. The only solution is to open the lib file in a word processor and editing out the quote character, or replacing it with two single quote (') characters. Kicad should do this replacement automatically to avoid this corruption or use a delimiter that cannot be used in the field.
This bug became apparent to me when I copy and pasted a string that had in the middle of it a dimension in units of inches and indicated inches with the double quote character. That particular field, Field 6, was being used as a description field.
This bug was found in Kicad installed from file KiCad-2010-
Well described report.
But there are probably more such cases.
I don't mind fixing this one, but it would be nice to be able to get our
arms around all of them at once. This is the second such report in the last
two months.
The solution is to use EscapedUTF8( ).c_str( ) to format the field, and it
will "escape" the interior double quote with a backslash.
The counterpart to
std::string EscapedUTF8( const wxString& aString );
is
int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize )
These two functions are a matched set, and reside in common/string.cpp. One
does the reverse of the other.
Installing them is not hard, but doing one per month is not fun.
I will fix this one, but plea for somebody to help me find all the cases
where this is going to be a problem moving forward.
I guess we can grep for
" \"%s\" "
which is probably a good way to find most of the problems NOW.