Skip to content

Commit 09dd2cd

Browse files
authored
don't limit outputTimestamp to zip (MS DOS) range (#312)
1 parent 1d239c0 commit 09dd2cd

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

src/main/java/org/apache/maven/shared/archiver/MavenArchiver.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ public class MavenArchiver {
9797
"${artifact.groupIdPath}/${artifact.artifactId}/" + "${artifact.baseVersion}/${artifact.artifactId}-"
9898
+ "${artifact.baseVersion}${dashClassifier?}.${artifact.extension}";
9999

100-
private static final Instant DATE_MIN = Instant.parse("1980-01-01T00:00:02Z");
101-
102-
private static final Instant DATE_MAX = Instant.parse("2099-12-31T23:59:59Z");
103-
104100
private static final List<String> ARTIFACT_EXPRESSION_PREFIXES;
105101

106102
static {
@@ -681,10 +677,7 @@ public void setBuildJdkSpecDefaultEntry(boolean buildJdkSpecDefaultEntry) {
681677
* @return the parsed timestamp as an {@code Optional<Instant>}, {@code empty} if input is {@code null} or input
682678
* contains only 1 character (not a number)
683679
* @since 3.6.0
684-
* @throws IllegalArgumentException if the outputTimestamp is neither ISO 8601 nor an integer, or it's not within
685-
* the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z as defined by
686-
* <a href="https://pkwaredownloads.blob.core.windows.net/pem/APPNOTE.txt">ZIP application note</a>,
687-
* section 4.4.6.
680+
* @throws IllegalArgumentException if the outputTimestamp is neither ISO 8601 nor an integer.
688681
* @see <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=74682318">Maven Wiki "Reproducible/Verifiable
689682
* Builds"</a>
690683
*/
@@ -702,11 +695,6 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp
702695
// Number representing seconds since the epoch
703696
if (isNumeric(outputTimestamp)) {
704697
final Instant date = Instant.ofEpochSecond(Long.parseLong(outputTimestamp));
705-
706-
if (date.isBefore(DATE_MIN) || date.isAfter(DATE_MAX)) {
707-
throw new IllegalArgumentException(
708-
"'" + date + "' is not within the valid range " + DATE_MIN + " to " + DATE_MAX);
709-
}
710698
return Optional.of(date);
711699
}
712700

@@ -716,11 +704,6 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp
716704
.withOffsetSameInstant(ZoneOffset.UTC)
717705
.truncatedTo(ChronoUnit.SECONDS)
718706
.toInstant();
719-
720-
if (date.isBefore(DATE_MIN) || date.isAfter(DATE_MAX)) {
721-
throw new IllegalArgumentException(
722-
"'" + date + "' is not within the valid range " + DATE_MIN + " to " + DATE_MAX);
723-
}
724707
return Optional.of(date);
725708
} catch (DateTimeParseException pe) {
726709
throw new IllegalArgumentException(

src/test/java/org/apache/maven/shared/archiver/MavenArchiverTest.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,26 +1313,6 @@ void testThrownParseOutputTimestampInstant(String outputTimestamp) {
13131313
.withCauseInstanceOf(DateTimeParseException.class);
13141314
}
13151315

1316-
@ParameterizedTest
1317-
@ValueSource(
1318-
strings = {
1319-
"0",
1320-
"1",
1321-
"9",
1322-
"1980-01-01T00:00:01Z",
1323-
"2100-01-01T00:00Z",
1324-
"2100-02-28T23:59:59Z",
1325-
"2099-12-31T23:59:59-01:00",
1326-
"1980-01-01T00:15:35+01:00",
1327-
"1980-01-01T10:15:35+14:00"
1328-
})
1329-
void testThrownParseOutputTimestampInvalidRange(String outputTimestamp) {
1330-
// date is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z
1331-
assertThatExceptionOfType(IllegalArgumentException.class)
1332-
.isThrownBy(() -> MavenArchiver.parseBuildOutputTimestamp(outputTimestamp))
1333-
.withMessageContaining("is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z");
1334-
}
1335-
13361316
@ParameterizedTest
13371317
@CsvSource({
13381318
"2011-12-03T10:15:30+01,1322903730",

0 commit comments

Comments
 (0)