Remove trailing space from media type for ots mapping
The regular expression in the new test is intended to match the
documented [1] ABNF for a media type:
type-name = reg-name
subtype-name = reg-name
reg-name = 1*127reg-name-chars
reg-name-chars = ALPHA / DIGIT / "!" /
"#" / "$" / "&" / "." /
"+" / "-" / "^" / "_"
Closes gh-29746
[1] https://datatracker.ietf.org/doc/html/rfc4288#section-4.2
This commit is contained in:
parent
c3eee4ad68
commit
387795d4db
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -128,7 +128,7 @@ public final class MimeMappings implements Iterable<MimeMappings.Mapping> {
|
||||||
mappings.add("otg", "application/vnd.oasis.opendocument.graphics-template");
|
mappings.add("otg", "application/vnd.oasis.opendocument.graphics-template");
|
||||||
mappings.add("oth", "application/vnd.oasis.opendocument.text-web");
|
mappings.add("oth", "application/vnd.oasis.opendocument.text-web");
|
||||||
mappings.add("otp", "application/vnd.oasis.opendocument.presentation-template");
|
mappings.add("otp", "application/vnd.oasis.opendocument.presentation-template");
|
||||||
mappings.add("ots", "application/vnd.oasis.opendocument.spreadsheet-template ");
|
mappings.add("ots", "application/vnd.oasis.opendocument.spreadsheet-template");
|
||||||
mappings.add("ott", "application/vnd.oasis.opendocument.text-template");
|
mappings.add("ott", "application/vnd.oasis.opendocument.text-template");
|
||||||
mappings.add("ogx", "application/ogg");
|
mappings.add("ogx", "application/ogg");
|
||||||
mappings.add("ogv", "video/ogg");
|
mappings.add("ogv", "video/ogg");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
@ -135,4 +136,11 @@ class MimeMappingsTests {
|
||||||
assertThat(unmodifiable.get("foo")).isNull();
|
assertThat(unmodifiable.get("foo")).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mimeTypesInDefaultMappingsAreCorrectlyStructured() {
|
||||||
|
String regName = "[A-Za-z0-9!#$&.+\\-^_]{1,127}";
|
||||||
|
Pattern pattern = Pattern.compile("^" + regName + "\\/" + regName + "$");
|
||||||
|
assertThat(MimeMappings.DEFAULT).allSatisfy((mapping) -> assertThat(mapping.getMimeType()).matches(pattern));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue