DieSchittigs / contao-content-api-bundle

Contao JSON-API
MIT License
41 stars 9 forks source link

Malformed UTF-8 characters #11

Closed hamidpeywasti closed 4 years ago

hamidpeywasti commented 5 years ago

Hi, I installed this in a Contao 4.6, but there is an error:

[2018-12-22 05:12:52] request.INFO: Matched route "content_api_sitemap". {"route":"content_api_sitemap","route_parameters":{"_route":"content_api_sitemap","_scope":"frontend","_token_check":false,"_controller":"DieSchittigs\\ContaoContentApiBundle\\Controller\\ContentApiController::sitemapAction"},"request_uri":"https://vatan.bio/api/sitemap","method":"HEAD"} [] [2018-12-22 05:12:52] security.INFO: Populated the TokenStorage with an anonymous Token. [] [] [2018-12-22 05:12:52] request.INFO: Matched route "content_api_sitemap". {"route":"content_api_sitemap","route_parameters":{"_route":"content_api_sitemap","_scope":"frontend","_token_check":false,"_controller":"DieSchittigs\\ContaoContentApiBundle\\Controller\\ContentApiController::sitemapAction"},"request_uri":"https://vatan.bio/api/sitemap","method":"GET"} [] [2018-12-22 05:12:52] security.INFO: Populated the TokenStorage with an anonymous Token. [] [] [2018-12-22 05:12:52] request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "Malformed UTF-8 characters, possibly incorrectly encoded" at /home/vatan/public_html/vendor/symfony/http-foundation/JsonResponse.php line 152 {"exception":"[object] (InvalidArgumentException(code: 0): Malformed UTF-8 characters, possibly incorrectly encoded at /home/vatan/public_html/vendor/symfony/http-foundation/JsonResponse.php:152)"} []

What's wrong?

saibotd commented 5 years ago

This should work now! Could you give it a try?

hamidpeywasti commented 5 years ago

Thank you, I'll try.

saibotd commented 5 years ago

Closing for now

reeLx commented 5 years ago

Hi. I get the same issue in a Contao 4.8. Could it be that your fix was just temporary?

When I try to open /api/page?url= it works only on pages without terminal42/contao-pageimage on it. There might be UTF-8 characters in the pageimage extension, which can't be encoded by the API

hamidpeywasti commented 5 years ago

Hi,

[2019-09-29 19:46:33] request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "Malformed UTF-8 characters, possibly incorrectly encoded" at /home/abcdef/public_html/vendor/symfony/http-foundation/JsonResponse.php line 167 {"exception":"[object] (InvalidArgumentException(code: 0): Malformed UTF-8 characters, possibly incorrectly encoded at /home/vatanplast/public_html/vendor/symfony/http-foundation/JsonResponse.php:167)"} []

saibotd commented 4 years ago

I've added a fix for terminal42/contao-pageimage and added a ctype check to ensure there are no crashes due to unencodable strings. Please give it a try

reeLx commented 4 years ago

I'm sorry for the late answer, at least here's my response. It works like a charm now; no more problems. Thank you!