Repository navigation
fix(hex_encode): stringify the argument like the other helpers - #344
Merged
Mzack9999 merged 1 commit intoOct 25, 2026
Merged
Conversation
hexutil.Encode takes any but reads only a string or a []byte and returns "" for anything else. hex_encode passed args[0] through untouched, and govaluate hands a numeric literal over as a float64, so hex_encode(1234) came back empty with no error while base64(1234) gives "MTIzNA==" and md5(1234) hashes the digits. toString is what the rest of the helpers take their input with, hex_decode included one line below.
CalvinTjoaquinn
force-pushed
the
fix/hex-encode-stringify
branch
from
September 29, 2026 06:24
aa26f91 to
e3f4f9e
Compare
dogancanbakir
approved these changes
Oct 21, 2026
Mzack9999
approved these changes
Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #358
hex_encode(1234)returns an empty string with no error, while every other encoding helper accepts a number.Why
hexutil.Encodein projectdiscovery/utils takesanybut reads only astringor a[]byte:hex_encodehandedargs[0]straight to it, and govaluate turns a numeric literal into afloat64, so the default branch ran and the result was empty. The repo's own test assertsbin_to_dec(1010)returnsfloat64(10), which is the same detail from the other side.toStringis what the rest of the helpers take their input with,hex_decodeincluded one line below, so that is what this uses.Verification
Against the current code:
The two passing rows are there to hold the string path and the convention this follows in place. The
hex_decoderow matters most: the round trip was silently lossy, returning "" rather than the digits.go test -race ./...passes andgolangci-lint run ./...reports 0 issues.The same argument applies to
hexutil.Encodeitself, which cannot tell an empty input from an unsupported type. Fixing it there would reach every caller, but it is a public function in another repo, so this PR keeps to the DSL side. Happy to open one against utils if you would rather have it there.Independent of #340, #341, #342 and #343. None of them touch these lines.