Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ampersand handling #692

Closed
robbrandt opened this issue Sep 19, 2015 · 9 comments
Closed

Ampersand handling #692

robbrandt opened this issue Sep 19, 2015 · 9 comments
Assignees
Labels
Milestone

Comments

@robbrandt
Copy link

I am using MOST 06.2, so this might be an old issue.

I am doing some heavy data processing while importing data. I am finding repeatedly, in many entities, that text values containing ampersands aren't handled nicely. The gist of the problem is that the data is initially persisted correctly, for example "A & B" as "A & B". However if that entity is gotten, manipulated and then persisted again (perhaps in a cascade) it is saved as "A & B". If it happens many times, it gets really ridiculous and causes validation errors related to string length. The latest example is a URL string query value, for example:

http://www.domain.com/WebSync/Pages/Team/TeamSchedule.aspx?association=10&sg=MBB&team=389

As a workaround, I am html_entity_decode() on these values after they are gotten, so that they will be persisted correctly. But I have now accumulated a long list of values I have to do this to.

@Guite Guite added the bug label Sep 19, 2015
@Guite Guite added this to the 0.7.0 milestone Sep 19, 2015
@Guite Guite self-assigned this Sep 19, 2015
@Guite
Copy link
Owner

Guite commented Sep 19, 2015

Maybe an easier (central) workaround until the issue is solved: lookup the formatTextualField method in the base entity class. There you will find this condition:

                if ($currentFunc == 'edit') {
                    // apply no changes when editing the content
                    return;
                }

Change it to:

                if (in_array($currentFunc, array('edit', 'yourImportFunction'))) {
                    // apply no changes when editing the content
                    return;
                }

@Guite
Copy link
Owner

Guite commented Sep 19, 2015

Or even better: override it in the child class like this:

                if ($currentFunc == 'yourImportFunction') {
                    return;
                }

                return parent::formatTextualField($fieldName, $currentFunc, $usesCsvOutput, $allowZero);

@cmfcmf
Copy link
Contributor

cmfcmf commented Sep 19, 2015

refs #624

@robbrandt
Copy link
Author

Is there a function that will clean up an entire object? I have some entities with one to many relations that of course have entire collections in them, and cascade persist. So keeping them "clean" is becoming incredibly unwieldy doing it one field at a time.

@Guite
Copy link
Owner

Guite commented Dec 8, 2015

Fixed in f4f1cd0

@Guite Guite closed this as completed Dec 8, 2015
@robbrandt
Copy link
Author

@Guite: in 0.7.0, is there a more complete fix implemented than the workaround in f4f1cd0? There were other characters than & involved, and I need to know if I will have to maintain strings here.

@Guite
Copy link
Owner

Guite commented Aug 3, 2016

No there isn't a better solution implemented yet. If you come up with something please propose it :-)

@Guite
Copy link
Owner

Guite commented Aug 5, 2016

Maybe the whole method is not required anymore in 1.4.3+ modules, because Twig is now used which should do output sanitising automatically. We need to recheck this.

@Guite Guite reopened this Aug 5, 2016
@Guite
Copy link
Owner

Guite commented Aug 17, 2016

Disabled the method for 1.4.x in 0d24a56

@Guite Guite closed this as completed Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants