contao / core-bundle

[READ-ONLY] Contao Core Bundle
GNU Lesser General Public License v3.0
122 stars 57 forks source link

[RTM] fix DropZone showing HTML in errors #1509

Closed fritzmg closed 6 years ago

fritzmg commented 6 years ago

This fixes #1506. Not the most elegant solution though. Fix is needed for #1507.

xchs commented 6 years ago

@fritzmg The PR should be targeted against the 4.4 branch, shouldn't it?

fritzmg commented 6 years ago

Hm, true, I mis-targeted because I have done this for a new feature (#1507).

fritzmg commented 6 years ago

I forcefully changed the base now... not sure if that was a good idea ;)

leofeyer commented 6 years ago

Wouldn't a simple strip_tags() do the job, too?

fritzmg commented 6 years ago

Well, the ResponseException is thrown in DC_Folder, however there I have no information about whether the response is for the DropZone or not. Unless we can assume that any AJAX Request wants the messages from the response in pure text instead of HTML?

leofeyer commented 6 years ago

Unless we can assume that any AJAX Request wants the messages from the response in pure text instead of HTML?

I guess we can safely assume this. 😉

fritzmg commented 6 years ago

Ok :). Then I guess

elseif ($blnIsAjax)
{
    throw new ResponseException(new Response(\strip_tags(\Message::generateUnwrapped()), 500));
}

is sufficient.

leofeyer commented 6 years ago

You don't need to prefix the strip_tags() function. It cannot be optimized by the OPcache.

fritzmg commented 6 years ago

PR updated.

fritzmg commented 6 years ago

@leofeyer this needs to be merged too - otherwise #1507 won't work properly :)

leofeyer commented 6 years ago

Since you did not like the strip_tags() approach, I have implemented something else in 8c99c38fdd5b435037ee546b26abe6f4fefd916d. Do you like it?

fritzmg commented 6 years ago

Looks good! This way "raw" error messages can be used somewhere else too.

leofeyer commented 6 years ago

I have backported the changes in a53201e0cbd96c177495b92fca298a4b75154ded.