You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/10/26 14:41:28 UTC
[commons-compress] branch master updated (ce9d2834 -> e2f64df6)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
from ce9d2834 Bump commons-io from 2.14.0 to 2.15.0
new 7e537873 Precompile regualr expression in ArArchiveInputStream.isBSDLongName(String)
new 6778bbf8 Precompile regular expression in ArArchiveInputStream.isGNULongName(String)
new ec5883b5 Precompile regular expression in TarArchiveEntry.parseInstantFromDecimalSeconds(String)
new e2f64df6 Precompile regular expression in ChangeSet.addDeletion(Change)
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/changes/changes.xml | 4 ++++
.../commons/compress/archivers/ar/ArArchiveInputStream.java | 10 +++++-----
.../commons/compress/archivers/tar/TarArchiveEntry.java | 5 +++--
.../java/org/apache/commons/compress/changes/ChangeSet.java | 13 +++++--------
4 files changed, 17 insertions(+), 15 deletions(-)
[commons-compress] 02/04: Precompile regular expression in ArArchiveInputStream.isGNULongName(String)
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 6778bbf8cfcbfe4fb621a16fb382da545c2192fe
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 26 10:25:09 2023 -0400
Precompile regular expression in
ArArchiveInputStream.isGNULongName(String)
---
src/changes/changes.xml | 1 +
.../apache/commons/compress/archivers/ar/ArArchiveInputStream.java | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6e1b7cfe..e8f2004b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -65,6 +65,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
<!-- FIX -->
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regualr expression in ArArchiveInputStream.isBSDLongName(String).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in ArArchiveInputStream.isGNULongName(String).</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io from 2.13.0 to 2.15.0.</action>
diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
index bbea19a4..06309fa4 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
@@ -58,7 +58,7 @@ public class ArArchiveInputStream extends ArchiveInputStream {
BSD_LONGNAME_PREFIX.length();
private static final Pattern BSD_LONGNAME_PATTERN = Pattern.compile("^" + BSD_LONGNAME_PREFIX + "\\d+");
private static final String GNU_STRING_TABLE_NAME = "//";
- private static final String GNU_LONGNAME_PATTERN = "^/\\d+";
+ private static final Pattern GNU_LONGNAME_PATTERN = Pattern.compile("^/\\d+");
/**
* Does the name look like it is a long name (or a name containing
* spaces) as encoded by BSD ar?
@@ -356,7 +356,7 @@ public class ArArchiveInputStream extends ArchiveInputStream {
* @see #isGNUStringTable
*/
private boolean isGNULongName(final String name) {
- return name != null && name.matches(GNU_LONGNAME_PATTERN);
+ return name != null && GNU_LONGNAME_PATTERN.matcher(name).matches();
}
/*
[commons-compress] 04/04: Precompile regular expression in ChangeSet.addDeletion(Change)
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit e2f64df6e52908ab7a8f2118bf286d5d29483eb6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 26 10:41:21 2023 -0400
Precompile regular expression in ChangeSet.addDeletion(Change)
---
src/changes/changes.xml | 1 +
.../java/org/apache/commons/compress/changes/ChangeSet.java | 13 +++++--------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c4f7565e..62bb98a4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -67,6 +67,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regualr expression in ArArchiveInputStream.isBSDLongName(String).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in ArArchiveInputStream.isGNULongName(String).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in TarArchiveEntry.parseInstantFromDecimalSeconds(String).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in ChangeSet.addDeletion(Change).</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io from 2.13.0 to 2.15.0.</action>
diff --git a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java b/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
index e99cb093..e1586690 100644
--- a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
+++ b/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
@@ -22,6 +22,7 @@ import java.io.InputStream;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
+import java.util.regex.Pattern;
import org.apache.commons.compress.archivers.ArchiveEntry;
@@ -71,16 +72,14 @@ public final class ChangeSet {
* the change which should result in an addition
*/
private void addAddition(final Change pChange) {
- if (Change.TYPE_ADD != pChange.type() ||
- pChange.getInput() == null) {
+ if (Change.TYPE_ADD != pChange.type() || pChange.getInput() == null) {
return;
}
if (!changes.isEmpty()) {
for (final Iterator<Change> it = changes.iterator(); it.hasNext();) {
final Change change = it.next();
- if (change.type() == Change.TYPE_ADD
- && change.getEntry() != null) {
+ if (change.type() == Change.TYPE_ADD && change.getEntry() != null) {
final ArchiveEntry entry = change.getEntry();
if (entry.equals(pChange.getEntry())) {
@@ -110,20 +109,18 @@ public final class ChangeSet {
return;
}
final String source = pChange.targetFile();
-
+ final Pattern pattern = Pattern.compile(source + "/.*");
if (source != null && !changes.isEmpty()) {
for (final Iterator<Change> it = changes.iterator(); it.hasNext();) {
final Change change = it.next();
if (change.type() == Change.TYPE_ADD
&& change.getEntry() != null) {
final String target = change.getEntry().getName();
-
if (target == null) {
continue;
}
-
if (Change.TYPE_DELETE == pChange.type() && source.equals(target) ||
- Change.TYPE_DELETE_DIR == pChange.type() && target.matches(source + "/.*")) {
+ Change.TYPE_DELETE_DIR == pChange.type() && pattern.matcher(target).matches()) {
it.remove();
}
}
[commons-compress] 03/04: Precompile regular expression in TarArchiveEntry.parseInstantFromDecimalSeconds(String)
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit ec5883b518ebc09fea66e1a44ba3d8d1ca60778e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 26 10:28:02 2023 -0400
Precompile regular expression in
TarArchiveEntry.parseInstantFromDecimalSeconds(String)
---
src/changes/changes.xml | 1 +
.../org/apache/commons/compress/archivers/tar/TarArchiveEntry.java | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e8f2004b..c4f7565e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,6 +66,7 @@ The <action> type attribute can be add,update,fix,remove.
<!-- FIX -->
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regualr expression in ArArchiveInputStream.isBSDLongName(String).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in ArArchiveInputStream.isGNULongName(String).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in TarArchiveEntry.parseInstantFromDecimalSeconds(String).</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io from 2.13.0 to 2.15.0.</action>
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index fdc49d69..a0a80cf4 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -41,6 +41,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.compress.archivers.ArchiveEntry;
@@ -226,7 +227,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
* which is 19 digits.
* </p>
*/
- private static final String PAX_EXTENDED_HEADER_FILE_TIMES_PATTERN = "-?\\d{1,19}(?:\\.\\d{1,19})?";
+ private static final Pattern PAX_EXTENDED_HEADER_FILE_TIMES_PATTERN = Pattern.compile("-?\\d{1,19}(?:\\.\\d{1,19})?");
private static FileTime fileTimeFromOptionalSeconds(final long seconds) {
if (seconds <= 0) {
@@ -278,7 +279,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
private static Instant parseInstantFromDecimalSeconds(final String value) throws IOException {
// Validate field values to prevent denial of service attacks with BigDecimal values (see JDK-6560193)
- if (!value.matches(TarArchiveEntry.PAX_EXTENDED_HEADER_FILE_TIMES_PATTERN)) {
+ if (!TarArchiveEntry.PAX_EXTENDED_HEADER_FILE_TIMES_PATTERN.matcher(value).matches()) {
throw new IOException("Corrupted PAX header. Time field value is invalid '" + value + "'");
}
[commons-compress] 01/04: Precompile regualr expression in ArArchiveInputStream.isBSDLongName(String)
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 7e5378737a3c83f0cfd1fc240e28ae6df71e36df
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 26 10:16:28 2023 -0400
Precompile regualr expression in
ArArchiveInputStream.isBSDLongName(String)
---
src/changes/changes.xml | 1 +
.../apache/commons/compress/archivers/ar/ArArchiveInputStream.java | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0c65d5ef..6e1b7cfe 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -64,6 +64,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
<!-- FIX -->
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regualr expression in ArArchiveInputStream.isBSDLongName(String).</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io from 2.13.0 to 2.15.0.</action>
diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
index 08b03cd3..bbea19a4 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
@@ -22,6 +22,7 @@ import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
+import java.util.regex.Pattern;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
@@ -55,8 +56,7 @@ public class ArArchiveInputStream extends ArchiveInputStream {
static final String BSD_LONGNAME_PREFIX = "#1/";
private static final int BSD_LONGNAME_PREFIX_LEN =
BSD_LONGNAME_PREFIX.length();
- private static final String BSD_LONGNAME_PATTERN =
- "^" + BSD_LONGNAME_PREFIX + "\\d+";
+ private static final Pattern BSD_LONGNAME_PATTERN = Pattern.compile("^" + BSD_LONGNAME_PREFIX + "\\d+");
private static final String GNU_STRING_TABLE_NAME = "//";
private static final String GNU_LONGNAME_PATTERN = "^/\\d+";
/**
@@ -82,7 +82,7 @@ public class ArArchiveInputStream extends ArchiveInputStream {
* @since 1.3
*/
private static boolean isBSDLongName(final String name) {
- return name != null && name.matches(BSD_LONGNAME_PATTERN);
+ return name != null && BSD_LONGNAME_PATTERN.matcher(name).matches();
}
/**