Diagnose RescueGroups response encoding by adding encoding scheme in log And Repair Mojibake - #158
Diagnose RescueGroups response encoding by adding encoding scheme in log And Repair Mojibake#158patrickZWY wants to merge 14 commits into
Conversation
|
Work in progress… will see better whether funky word is caused by no encoding scheme and resorting to default Latin-1 |
|
temporarily removed debug flag to try logging from real rescue api, currently api is down. try it at another time. |
|
From log, we get: and: and: It seems that text is already corrupted when we received it. Do minimal repair instead. |
… and not disrupt normal words
…anity check logging
|
Added general mojibake repair, behavior tests, regression tests, comments for mastodon impl details, sanity check logging post repair. Will need to switch dev setting back to normal when finished. Also more testing of ftfy capabilities (for example its fix and explain may be useful for logging) |
|
As the log shows in descriptionHtml and descriptionText: the text is already corrupted somewhere upstream before requested by us, so the chain of events likely is: |
|
changed to a more conservative way of using mojibake by choosing when and which to repair and not so that stuff like valid à and  text remains unchanged. |
|
under current conservative rule, these will not be repaired: missing byte replaced by a space such as voilà le travail will not become violà le travail. if clean and corrupted text mixed on the same line, will not repair. lossy corruption that cannot be recovered reliably. so repair is for complete, recognizable encoding mistakes, but anything that requires guessing will remain the same. |
|
Things that may be correct but may be over-corrected by ftfy: “hello” because of curly quotes become straight quotes. HTML entities remaining in the text like """. CJK text normalized. typographical stuff like "fl".
|
|
After second thoughts, fix and explain feature can be used more widely as long as it doesn’t touch anything beyond the textual content of the post. |
No description provided.