ssddanbrown / rss

PROJECT MIGRATED TO CODEBERG -- A simple twitter-feed-style RSS aggregator written in PHP, Laravel, Inertia.js, Tailwind and Vue.js
https://codeberg.org/danb/rss
MIT License
530 stars 20 forks source link

500 server error on malformed UTF-8 characters #1

Closed droM4X closed 2 years ago

droM4X commented 2 years ago

Hey, Nice little rss reader 🤟 It seems one of my feed have encoding problems, so the app shows error 500. Can you fixed it? Thanks in advance.

[2022-07-04 11:21:51] production.ERROR: Malformed UTF-8 characters, possibly incorrectly encoded {"exception":"[object] (InvalidArgumentException(code: 0): Malformed UTF-8 characters, possibly incorrectly encoded at /app/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php:91)

ssddanbrown commented 2 years ago

Thanks @droM4X, Do you perhaphs have a feed URL to share that causes such a scenario? Just need to be able to reproduce the issue.

minyk commented 2 years ago

@ssddanbrown in my case, https://www.mail-archive.com/dev@spark.apache.org/maillist.xml is problematic. this url is came from here: https://www.mail-archive.com/dev@spark.apache.org/info.html

minyk commented 2 years ago

@ssddanbrown in my case, https://www.mail-archive.com/dev@spark.apache.org/maillist.xml is problematic. this url is came from here: https://www.mail-archive.com/dev@spark.apache.org/info.html

URL encoded address is just fine to me.

droM4X commented 2 years ago

At the moment, I got 500 for multiple feeds what is worked in the last 24 hours. For example: https://24.hu/feed/ https://telex.hu/rss 24.hu is the biggest hungarian news site

Error is same in laravel.log:

production.ERROR: Malformed UTF-8 characters, possibly incorrectly encoded {"exception":"[object] (InvalidArgumentException(code: 0): Malformed UTF-8 characters, possibly incorrectly encoded at /app/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php:91)

droM4X commented 2 years ago

Also sometimes I got js error and blank screen and cache clear isn't help at all. Got this yesterday evening, but it worked again in the morning. At the moment I get this error again. Maybe its cause this problem?

VM113:1 Uncaught (in promise) SyntaxError: Unexpected end of JSON input at JSON.parse () at Nf (app.ab3aa705.js:12:898) at app.ab3aa705.js:12:1766

ssddanbrown commented 2 years ago

@droM4X Thanks for the further info.

Using the provided feeds, I identified a case where this could occur, and have patched the scenario in v1.0.4. Note, this fix will only apply to new posts imported and posts updated from more recent fetches.

To prevent older posts in the database from being an issue, you may need to clear the post descriptions. If using our docker-compose setup this can be done like so:

docker-compose exec rss /usr/bin/php -r "(new SQLite3('/app/storage/database/database.sqlite'))->exec('UPDATE posts set description=\"\"');"

Post descriptions will be refreshed/updated for newer posts upon future imports.

Alterantively, you could just delete your post database, which would exist at database/database.sqlite in the mounted /app/storage volume, but this will remove any old posts you've collected over time. Anything recent should be re-imported at next app run.

droM4X commented 2 years ago

Just updated (thx for the favicon), run the fix, and it seems ok. I left this ticket open to test it today, will close tomorrow if everything is ok.

Thanks for the quick fix.