Skip to content

Commit 2322ef7

Browse files
authored
don't limit outputTimestamp to zip (MS DOS) range (#311)
1 parent cb15fc5 commit 2322ef7

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

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

Lines changed: 2 additions & 20 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 {
@@ -719,8 +715,7 @@ public void setBuildJdkSpecDefaultEntry(boolean buildJdkSpecDefaultEntry) {
719715
* @return the parsed timestamp, may be <code>null</code> if <code>null</code> input or input contains only 1
720716
* character
721717
* @since 3.5.0
722-
* @throws IllegalArgumentException if the outputTimestamp is neither ISO 8601 nor an integer, or it's not within
723-
* the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z
718+
* @throws IllegalArgumentException if the outputTimestamp is neither ISO 8601 nor an integer
724719
* @deprecated Use {@link #parseBuildOutputTimestamp(String)} instead.
725720
*/
726721
@Deprecated
@@ -756,10 +751,7 @@ public Date configureReproducible(String outputTimestamp) {
756751
* @return the parsed timestamp as an {@code Optional<Instant>}, {@code empty} if input is {@code null} or input
757752
* contains only 1 character (not a number)
758753
* @since 3.6.0
759-
* @throws IllegalArgumentException if the outputTimestamp is neither ISO 8601 nor an integer, or it's not within
760-
* the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z as defined by
761-
* <a href="https://pkwaredownloads.blob.core.windows.net/pem/APPNOTE.txt">ZIP application note</a>,
762-
* section 4.4.6.
754+
* @throws IllegalArgumentException if the outputTimestamp is neither ISO 8601 nor an integer.
763755
* @see <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=74682318">Maven Wiki "Reproducible/Verifiable
764756
* Builds"</a>
765757
*/
@@ -777,11 +769,6 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp
777769
// Number representing seconds since the epoch
778770
if (isNumeric(outputTimestamp)) {
779771
final Instant date = Instant.ofEpochSecond(Long.parseLong(outputTimestamp));
780-
781-
if (date.isBefore(DATE_MIN) || date.isAfter(DATE_MAX)) {
782-
throw new IllegalArgumentException(
783-
"'" + date + "' is not within the valid range " + DATE_MIN + " to " + DATE_MAX);
784-
}
785772
return Optional.of(date);
786773
}
787774

@@ -791,11 +778,6 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp
791778
.withOffsetSameInstant(ZoneOffset.UTC)
792779
.truncatedTo(ChronoUnit.SECONDS)
793780
.toInstant();
794-
795-
if (date.isBefore(DATE_MIN) || date.isAfter(DATE_MAX)) {
796-
throw new IllegalArgumentException(
797-
"'" + date + "' is not within the valid range " + DATE_MIN + " to " + DATE_MAX);
798-
}
799781
return Optional.of(date);
800782
} catch (DateTimeParseException pe) {
801783
throw new IllegalArgumentException(

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

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

1428-
@ParameterizedTest
1429-
@ValueSource(
1430-
strings = {
1431-
"0",
1432-
"1",
1433-
"9",
1434-
"1980-01-01T00:00:01Z",
1435-
"2100-01-01T00:00Z",
1436-
"2100-02-28T23:59:59Z",
1437-
"2099-12-31T23:59:59-01:00",
1438-
"1980-01-01T00:15:35+01:00",
1439-
"1980-01-01T10:15:35+14:00"
1440-
})
1441-
void testThrownParseOutputTimestampInvalidRange(String outputTimestamp) {
1442-
// date is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z
1443-
assertThatExceptionOfType(IllegalArgumentException.class)
1444-
.isThrownBy(() -> parseBuildOutputTimestamp(outputTimestamp))
1445-
.withMessageContaining("is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z");
1446-
}
1447-
14481428
@ParameterizedTest
14491429
@CsvSource({
14501430
"2011-12-03T10:15:30+01,1322903730",

0 commit comments

Comments
 (0)