Diagnose RescueGroups response encoding by adding encoding scheme in log And Repair Mojibake - #158
patrickZWY 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. |
| post_kind, | ||
| reply_number, | ||
| pprint.pformat(text), | ||
| ) |
There was a problem hiding this comment.
Is there a reason you want this in Mastodon instead of rescue_groups? I think the bad text issues is on the rescue groups API and would apply to all Posters right?
Or is there a Mastodon specific reason that causes the bad text?
There was a problem hiding this comment.
this was supposed to be a post-fix/correction check to log any remaining "malformed" text that should have been fixed previously in rescue_groups. so if anything that should be "fixed" is not fixed up to this point, it will be logged. this part is pretty much extra defensive coding so we can remove it if you think this is a bit extra (which is kinda why i put it here in mastodon because i don't want to pollute the main rescue_groups file with defensive programming stuff)
No description provided.