-
Notifications
You must be signed in to change notification settings - Fork 955
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
Ignore binary data in config backup #3453
Comments
You have few options. string.encode("UTF-8", invalid: replace, undef: replace, replace: '?')
string.b The first returns the string asUTF-8 replacing non-UTF-8 with ?. The second returns binary string, which is basically encode-less 8bit clean. |
Bit less ugly version
The problem is that the regex string itself is assumed to be UTF-8, and what you're inputting is not. I'm not sure if either is right way to do it. EDIT. I think this is the right way to do it:
https://ruby-doc.org/core-3.1.1/Regexp.html
|
I got it to work, based on the first part of your comment (funny, the mail notification shows only part of a comment and I did not know that, so did not see the rest of your comment when started experimenting, based on your comment).
Also, I put the gsub in the wrong part (config instead of version). I now have:
I'm not sure how many people have issues with the binary data, should I create a PR for it? |
Describe the problem
My Netgear switch produced a line of binary data that changes each time a config dump is made. This means there is always a config change and it triggers a new config to be saved and a notification to be sent, even though there were no config changes.
So far I have deducted that the binary block always starts with \x82 and ends with \xB8 (some more bytes could be static, but this seems to be enough to recognize the line):
I added a line like this to netgear.rb:
And added
# encoding: US-ASCII
at the top to fix the errorinvalid multibyte escape: /(\\x82.*)/ (SyntaxError)
However, this does not seem to work.
I have very little experience with Ruby, so I hope someone can help me write the right line to ignore changes like above when checking for config changes.
Expected behavior
The binary data being ignored in config backups
Configuration
See above
Logs
N/A
Running environment (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: