Webonaute / DoctrineFixturesGeneratorBundle

Generate Fixture from your existing data in your database. You can specify the Entity name and the IDs you want to import in your fixture.
63 stars 47 forks source link

Escape text fields #10

Closed SergeC closed 9 years ago

SergeC commented 9 years ago

Some of my fields contain HTML and they are exported incorrectly when double quotes is in text. I've added htmlentities at line 263 $setValue = '"' . htmlentities($value) . '"'; to \Webonaute\DoctrineFixturesGeneratorBundle\Tool\FixtureGenerator::generateFixtureItemStub

SergeC commented 9 years ago

This should be better: $setValue = "<<<EOT $value EOT".PHP_EOL;

Webonaute commented 9 years ago

Please provide a patch and I will include it with pleasure.

remedge commented 9 years ago

I faced with the same issue. Can I make a patch?

SergeC commented 9 years ago

@remedge Sure. Best way to do it with <<<.

remedge commented 9 years ago

@Webonaute please check the PR https://github.com/Webonaute/DoctrineFixturesGeneratorBundle/pull/18

Webonaute commented 9 years ago

anyone can confirm the patch is working or create a unit test for it? I am little busy actually and dont have time to test it until this weekend.

Webonaute commented 9 years ago

Please provide also an example of text that was not working and now working with the patch.

remedge commented 9 years ago

For example, text containig double quotes - '<a href="http://github.com/">bla bla bla</a>'

I can provide unit test but little later.

Webonaute commented 9 years ago

@remedge thank. I appreciate!

SergeC commented 9 years ago

Not tested but looks good.

Webonaute commented 9 years ago

@SergeC Sorry but I can't include a patch on a "it's look good" because it look good to mee too! but I dont want to include patch without at least 2 developer asserting its working after test or the patch author provide a proper unit test or I have personally tested it.

SergeC commented 9 years ago

@Webonaute @remedge Tested, worked for me. $setValue = '<<<EOT' . PHP_EOL . $value . PHP_EOL . 'EOT' . PHP_EOL; this works as well.

Webonaute commented 9 years ago

Added to master.