XML deserializer strips leading whitespace on loaddata
|Reported by:||Joseph-django@…||Owned by:||numerodix|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If an object instance has a character field and the value of that field starts with the tab character, loaddata removes that tab character when the loaded fixture is in XML format.
Note that the XML dump data does not strip this leading tab character. Also note that both the JSON dump and load data preserve the tab character.
I have not tested this with other whitespace characters. This can be easily reproduced by creating a simple model:
class Foobar(models.model) name = models.CharField(max_length=20)
And then creating an instance of that model (e.g, in Django Shell) with a name value of, e.g, "\tBaz" and then using the manage.py dumpdata with --format=xml.
Once the fixture has been generated, remove the existing instance (either by deleting it, or flushing the app data, or your preferred method) and then using manage.py loaddata to load the fixture. Note the instance's name no longer contains the tab character.
Change History (8)
comment:1 Changed 12 months ago by numerodix
- Cc numerodix@… added
- Needs documentation unset
- Needs tests unset
- Owner changed from nobody to numerodix
- Patch needs improvement unset
- Status changed from new to assigned
comment:5 in reply to: ↑ 3 Changed 12 months ago by EvilDMP
- Triage Stage changed from Unreviewed to Accepted