-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible deep-rooted issue of Conversion of String Encodings in http response body. #14
Comments
Extra infos: This only occurs when you get a (c) character. Some people at work have told me a quick-fix to this, which works well. But it would be good to know why when finding a (c) character using this library the encoding changes from UTF-8 (The standard one in our filesystem), to ASCII. A colleague of mine mentioned that maybe it's not ASCII but an "Unknown Binary" encoding, and that ASCII is being defaulted erroneously? Would it be possibly to have the http response body set to be the correct encoding at all times? |
|
This is possibly addressed by #17, can you check if that will work for you? You'll have to modify the code using Net::HTTP to set the new |
Sure thing. I'll have a go at this in the coming days. |
Managed to get a free 10 mins. A quick copy and paste of the 2 raw files in your SHA did not fix the issue. We currently fix the issue by running The io method does the following
The logger in question is a |
That's expected. As I wrote previously: "You'll have to modify the code using Net::HTTP to set the new |
Just curious with the fixes that went in in 2022 by yourself and merged by nurse whether this is in a future Ruby version. I have patched this in a gem I maintain here: https://github.com/site-prism/automation_helpers specifically with this patch class here: https://github.com/site-prism/automation_helpers/blob/main/lib/automation_helpers/patches/selenium_logger.rb Any thoughts/updates on what I could/should be doing? |
This pull request I discussed above is in Ruby 3.2. It was renamed from force_response_body_encoding to just response_body_encoding: 6233e6b Unfortunately, I'm at a conference and do not currently have time to look at the links you sent. |
Cheers. That's great to hear. In the next week or so I'll re-test this on ruby 3.2 and update my findings. Obviously I'm assuming it isn't a backport candidate as it's just a cosmetic feature. The links I sent were to a patch based on date / gem version. So I'll need to factor in this and add a date much further in the future. |
As an update. Real life got in the way. I'm still nowhere near ready to verify this is fixed or not. But I will get to it. At some point :D |
Hi @jeremyevans - Would it be possible to include the string representation of the site I scanned in the minitest suite. I have just re-tested on ruby Console warns (In red)
A small sample script (Using capybara) is as follows (Some bits ommitted)
|
@luke-hill I'm not sure. However, the question doesn't seem related to net-http. If you are not already, you may want to try |
Currently I have a 1-line patch which is. The logger does currently log to a file, this is deliberate. What I'm looking for is something to be fixed here so that I don't need to run the patch. If I need to retain the patch because the issue isn't fixed that's fine. Just thought I'd mention this hasn't fixed the underlying bug |
Apparently, your patch is to a logger. If you provide your logger an already open File instance in binary mode, shouldn't that resolve the problem without the need to patch? This doesn't sound like a bug at all, it sounds like an improper Logger configuration issue. Can you explain why you think this is a net-http issue? |
Because the error message is generated there and I'll be honest it's been over 3.5 years since I first found this. So I'm not 100% sure. My original work was done here: site-prism/automation_helpers@e4c8597 from February 2021 and I'd been suffering with it for a while before that. The Logger is just configured out of the box, no customisations e.t.c. - imo if the ruby Logger out of the box cannot handle the |
I'm going to close this now, since it isn't a bug in net-http. It doesn't appear to be a bug in Logger, either. If you can come up with a self-contained reproducible example that uses Logger and no other libraries, please post an issue in the logger repository. |
Thanks for your pointers. It's likely I'm going to need some help though. As when dieting it down it is only occuring when running in debug mode in RubyMine. I've also stripped away as much as I can to reliably re-generate it. I've got it down to 15 lines. If you can advise what to do next I would be greatly appreciative.
The file produced by the ruby logger is around 60 lines big.
I also wrote a bug a while back for selenium which didn't get very far. |
If this is only happening in debug mode in RubyMine, maybe you should ask them? |
Thankyou. I've raised it in the tracker there. I imagine all 3 areas are likely to point me in circles so I'll post an update here as/when I have updates |
There is no need to post an update here. This is not a net-http issue, and this is not a general support forum. |
Preface
This is a bit of a long convoluted chain (So apologies in advance). I'm not even sure if this is 100% fixable. But I'll post it here and try include as much info.
When using
Selenium::Webdriver.logger
in standard selenium practice, you can pipe debug messages. The following issue occurs (Page under test is: https://www.citizensadvice.org.uk/immigration/ - A national charity website).Simple reproduction case
©
character.Kernel.warn
messageRoot cause
The root cause issue (I believe), is with this process flow. The capitalised letters refer to which library is doing the code processing at that time.
Next steps?
I am not 100% sure. I think it would be nice to know why this encoding conversion is happening. I can patch it fine my end. But it has been mentioned to try trace exactly where / why it's occurring.
The text was updated successfully, but these errors were encountered: