codefog / contao-haste

Haste is a collection of tools and classes to ease working with Contao
http://codefog.pl/extension/haste.html
MIT License
43 stars 24 forks source link

Fix issue of broken response which is caused by replacing insert tags #132

Closed dmolineus closed 5 years ago

dmolineus commented 5 years ago

Fix issue of broken response which is caused by replacing insert tags in the json encoded content.

Background: Insert tags might return html with quotes. These quotes will break the json string.

Solution: Replace insert tags before encoding.

fritzmg commented 5 years ago

Keep in mind though that this will not replace any insert tags that are contained within objects, since InsertTags::replaceRecursively only applies itself recursively to arrays, not any iterable object. Should be an edge case though.

Toflar commented 5 years ago

This binds the response to the insert tags which violates separation of concerns imho. The response is there to send a proper response. It should not do any other string manipulation in my opinion.

qzminski commented 5 years ago

The base Response class already does replace insert tags so…

dmolineus commented 5 years ago

I actually agree with @Toflar. There are cases where I do not want to replace the insert tags. I added it to not add a bc break.

At least it should be possible to disable the behaviour.

Toflar commented 5 years ago

Ah I see. Okay then.