Skip to content

Commit

Permalink
Merge pull request #50 from sara-nl/fix-null-byte
Browse files Browse the repository at this point in the history
Strip null byte in token to avoid warnings
  • Loading branch information
onnozweers authored Jan 29, 2025
2 parents 6c8fcc6 + fa8f725 commit ad8c229
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ada/ada
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ view_token() {
echo "$payload" | jq '. | .exp |= todate | .nbf |= todate | .iat |= todate'
else
# Not an OIDC token; probably a Macaroon
macaroon_decoded=$(echo "$token" | base64 -d 2>/dev/null | awk '{print substr($0, 5)}' 2>/dev/null)
macaroon_decoded=$(echo "$token" | base64 -d 2>/dev/null | awk '{print substr($0, 5)}' 2>/dev/null | tr -d '\0')

# Check if decoding succeeded
if [ -z "$macaroon_decoded" ]; then
Expand Down Expand Up @@ -716,7 +716,7 @@ check_token() {
# Macaroon Token (assume it's base64 encoded)
$debug && echo "Checking Macaroon token..."

macaroon_decoded=$(echo "$token" | base64 -d 2>/dev/null | awk '{print substr($0, 5)}' 2>/dev/null)
macaroon_decoded=$(echo "$token" | base64 -d 2>/dev/null | awk '{print substr($0, 5)}' 2>/dev/null | tr -d '\0')

# Check if decoding succeeded
if [ -z "$macaroon_decoded" ]; then
Expand Down

0 comments on commit ad8c229

Please sign in to comment.