Files
news.gitea.happylizard.me/bin/gems/ethon-0.16.0/lib/ethon/easy/util.rb
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

29 lines
642 B
Ruby

# frozen_string_literal: true
module Ethon
class Easy # :nodoc:
# This module contains small helpers.
#
# @api private
module Util
# Escapes zero bytes in strings.
#
# @example Escape zero bytes.
# Util.escape_zero_byte("1\0")
# #=> "1\\0"
#
# @param [ Object ] value The value to escape.
#
# @return [ String, Object ] Escaped String if
# zero byte found, original object if not.
def escape_zero_byte(value)
return value unless value.to_s.include?(0.chr)
value.to_s.gsub(0.chr, '\\\0')
end
extend self
end
end
end