Defect #44603
openField wrapper is wrongly detected as a single quote when importing a CSV file that contains apostrophes
Description
The CSV import detects the field wrapper automatically (#39511). However, when a CSV file has no wrapped fields and some values contain apostrophes, the wrapper is wrongly detected as a single quote, and the file cannot be parsed with that setting.
To reproduce the problem, save the following content as a CSV file and upload it on the user import page. "Single quote" is selected as the field wrapper, although "Double quote" is expected.
login,firstname,lastname,mail jobrien,John,O'Brien,jobrien@example.net dwilliams,De'Andre,Williams,dwilliams@example.net soconnor,Sean,O'Connor,soconnor@example.net
This happens because Import#set_default_settings chooses the wrapper by comparing how many times " and ' appear at the beginning of the file. The file above contains no double quotes and three apostrophes.
The attached patch fixes this by counting only the quote characters that actually wrap a field, that is, those placed at both ends of a field. When neither character wraps any field, the double quote is still used, as before.
Files
Updated by Go MAEDA about 1 month ago
- Related to Feature #39511: Auto-detection of field wrapper type when importing CSV file added
Updated by Go MAEDA about 1 month ago
- Affected version set to 6.0.0
Updated by Go MAEDA about 1 month ago
- Target version changed from Candidate for next minor release to 6.1.6
Setting the target version to 6.1.6.