PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: go-webauthn/webauthn (go)

Issue:
Strip base64 padding in protocol.URLEncodedBase64
### Description

(version: github.com/go-webauthn/webauthn v0.5.0)

It seems the type `protocol.URLEncodedBase64` is, correctly, decoding base64 without padding. ([ref](https://w3c.github.io/webauthn/#base64url-encoding)) however, a frontend tool I'm using to implement webauthn seems to be adding padding to the `publicKey.response.userHandle`.

Now I can strip this out myself, but would it be incorrect for this library to conveniently strip padding automatically given that it's not meant to be there anyway?

### Use Case

_No response_

### Documentation

_No response_

Pull request:
feat(protocol): ignore padding for base64 url encoding
This adds support to ignore the trailing padding of base64 URL encoded bytes.

Closes #93

Patch:
diff --git a/protocol/base64.go b/protocol/base64.go
index 99362b2..37a151b 100644
--- a/protocol/base64.go
+++ b/protocol/base64.go
@@ -22,8 +22,13 @@ func (e *URLEncodedBase64) UnmarshalJSON(data []byte) error {
 		return nil
 	}
 
+	// TODO: Investigate this line. It is commented as trimming the leading spaces but appears to trim the leading and trailing double quotes instead.
 	// Trim the leading spaces
 	data = bytes.Trim(data, "\"")
+
+	// Trim the trailing equal characters.
+	data = bytes.TrimRight(data, "=")
+
 	out := make([]byte, base64.RawURLEncoding.DecodedLen(len(data)))
 	n, err := base64.RawURLEncoding.Decode(out, data)
 	if err != nil {


Test patch:
diff --git a/protocol/attestation_test.go b/protocol/attestation_test.go
index 2bee34d..cfe5e24 100644
--- a/protocol/attestation_test.go
+++ b/protocol/attestation_test.go
@@ -91,7 +91,7 @@ var testAttestationOptions = []string{
 		"user": {
 			"name": "self",
 			"displayName": "self",
-			"id": "2iEAAAAAAAAAAA"
+			"id": "2iEAAAAAAAAAAA=="
 		},
 		"pubKeyCredParams": [
 			{
@@ -116,7 +116,7 @@ var testAttestationOptions = []string{
 		"user": {
 			"name": "flort",
 			"displayName": "flort",
-			"id": "1DMAAAAAAAAAAA"
+			"id": "1DMAAAAAAAAAAA=="
 		},
 		"pubKeyCredParams": [
 			{
@@ -142,7 +142,7 @@ var testAttestationOptions = []string{
 		  "user": {
 			"name": "testuser1",
 			"displayName": "testuser1",
-			"id": "1zMAAAAAAAAAAA"
+			"id": "1zMAAAAAAAAAAA=="
 		  },
 		  "pubKeyCredParams": [
 			{