Restrict space-only keys (#6431)

This commit is contained in:
Takamasa Matsui 2024-05-10 03:05:04 +09:00 committed by GitHub
parent 0d2d67efe4
commit ca798212a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -127,7 +127,7 @@ public final class W3CBaggagePropagator implements TextMapPropagator {
* @return whether the name is valid.
*/
private static boolean isValidBaggageKey(String name) {
return name != null && !name.isEmpty() && StringUtils.isPrintableString(name);
return name != null && !name.trim().isEmpty() && StringUtils.isPrintableString(name);
}
/**

View File

@ -448,6 +448,7 @@ class W3CBaggagePropagatorTest {
.put("\2ab\3cd", "wacky key nonprintable")
.put(null, "null key")
.put("nullvalue", null)
.put(" ", "key is only space")
.build();
W3CBaggagePropagator propagator = W3CBaggagePropagator.getInstance();
Map<String, String> carrier = new HashMap<>();