Skip to content

Refactor ronin/support/encoding/base64 to not use the Base64 library#563

Closed
moozzi wants to merge 46 commits into1.2.0from
remove_base64_dependency
Closed

Refactor ronin/support/encoding/base64 to not use the Base64 library#563
moozzi wants to merge 46 commits into1.2.0from
remove_base64_dependency

Conversation

@moozzi
Copy link
Member

@moozzi moozzi commented Feb 9, 2025

* Also add `String#smtp_escape`, `String#smtp_encode`, `String#smtp_unescape`,
  and `String#smtp_decode` as aliases to `String#quoted_printable_*` methods.
* This matches the other `Encoding` modules.
* Because `URI::QueryParams::Mixin` uses `module_eval` to re-alias
  the `query=` method, this causes `query=` to get aliased to itself.
* Decoding [Perl Unicode Named Characters][1] is currently not supported and
  will raise a `NotImplementedError`.

[1]: https://www.perl.com/pub/2012/04/perlunicook-unicode-named-characters.html/
* Added `Network::Defang::Mixin` (issue #541).
* Added `String#refang` (issue #517).
* Added `URI::HTTP#defang` (issue #516).
* Added `IPAddr#defang` (issue #542).
* Also added `Network::Wildcard#regex` which is used to match hostnames
  against the wildcard template.
Copy link
Member

@postmodern postmodern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor naming change suggestions.

when nil then ::Base64.encode64(data)
when :strict then strict_encode64(data)
when :url_safe then urlsafe_encode64(data)
when nil then encode64(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline the encode64 logic directly into encode.

when nil then ::Base64.decode64(data)
when :strict then strict_decode64(data)
when :url_safe then urlsafe_decode64(data)
when nil then decode64(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline the decode64 logic directly into decode.

# @return [String]
# The Base64 encoded data.
#
def self.encode64(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove encode64.

# @return [String]
# The decoded data.
#
def self.decode64(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove decode64.

# @return [String]
# The Base64 strict encoded data.
#
def self.strict_encode64(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the 64 suffix.

# @return [String]
# The strict decoded data.
#
def self.strict_decode64(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the 64 suffix.

# @return [String]
# The Base64 url-safe encoded data.
#
def self.urlsafe_encode64(data, padding: true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to encode_urlsafe.

# @return [String]
# The url-safe decoded data.
#
def self.urlsafe_decode64(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to decode_urlsafe.

@postmodern
Copy link
Member

I will probably need to manually cherry-pick your commits out since you merged main back into the branch.

@moozzi
Copy link
Member Author

moozzi commented Feb 16, 2025

I will probably need to manually cherry-pick your commits out since you merged main back into the branch.

Damn.. I don't know when it happened.. I'll create new PR for that

@moozzi moozzi closed this Feb 18, 2025
@moozzi moozzi deleted the remove_base64_dependency branch February 18, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants