indes / flowerss-bot

A telegram bot for rss reader. 一个支持应用内阅读的 Telegram RSS Bot。
https://flowerss-bot.now.sh/
MIT License
1.81k stars 237 forks source link

fix: error with gbk encoding #187

Closed hellodword closed 1 year ago

hellodword commented 1 year ago

我不太确定这段代码的初衷(似乎是为了处理某些不标准编码导致的乱码?):

https://github.com/indes/flowerss-bot/blob/5c856b58ad7acb98c8f0525f4c5488f4228b8390/internal/fetch/fetch.go#L19-L31

但是它会导致 encoding 为 gbk 的 feed 出现乱码

<?xml version="1.0" encoding="gbk"?>

简单复现:

f, _ := rss.FetchByFunc(fetch.FetchFunc(client.NewHttpClient(client.WithTimeout(time.Minute))), "https://www.52pojie.cn/forum.php?mod=rss")
fmt.Println(f.Title, f.Description)
indes commented 1 year ago

74417e757cb9b1084f650c25d6a4f0ec184322be 是在这个commit引入的逻辑,应该是处理某些特殊xml解析异常。现在已经找不到当时的badcase,先合该代码,后续发现异常情况再进行修复。

codecov-commenter commented 1 year ago

Codecov Report

Merging #187 (4b0e339) into master (5c856b5) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #187   +/-   ##
=======================================
  Coverage   11.06%   11.06%           
=======================================
  Files          14       14           
  Lines         660      660           
=======================================
  Hits           73       73           
  Misses        577      577           
  Partials       10       10           
Flag Coverage Δ
unittests 11.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.