Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion zap/src/main/java/org/parosproxy/paros/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
// ZAP: 2023/09/14 Lock home directory.
// ZAP: 2024/04/25 Add new autoTagScanner regex patterns when upgrading from 2.14 or earlier.
// ZAP: 2024/11/06 Add branding related constants.
// ZAP: 2025/11/10 Updated VERSION_TAG.
package org.parosproxy.paros;

import java.io.File;
Expand Down Expand Up @@ -209,7 +210,7 @@ public final class Constant {
private static final String VERSION_ELEMENT = "version";

// Accessible for tests
static final long VERSION_TAG = 20016001;
static final long VERSION_TAG = 20017000;

// Old version numbers - for upgrade
private static final long V_2_14_0_TAG = 20014000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ abstract class AbstractStreamHttpEncoding implements HttpEncoding {

private static final int BUFFER_SIZE = 2048;

private static final byte[] EMPTY = {};

private final OutputStreamSupplier outputStreamSupplier;
private final InputStreamSupplier inputStreamSupplier;

Expand All @@ -49,6 +51,10 @@ public byte[] encode(byte[] content) throws IOException {

@Override
public byte[] decode(byte[] content) throws IOException {
if (content.length == 0) {
return EMPTY;
}

ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ByteArrayInputStream bais = new ByteArrayInputStream(content);
InputStream is = inputStreamSupplier.get(bais)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class HttpEncodingDeflateUnitTest {
private static final byte[] CONTENT = "Content 123 ABC".getBytes(StandardCharsets.UTF_8);
private static final byte[] CONTENT_ENCODED = deflate(CONTENT);

private static final byte[] EMPTY_CONTENT = {};
private static final byte[] EMPTY_CONTENT_ENCODED = deflate(EMPTY_CONTENT);

private HttpEncodingDeflate encoding = HttpEncodingDeflate.getSingleton();

@Test
Expand All @@ -55,6 +58,30 @@ void shouldDecodeContent() throws IOException {
assertThat(decodedContent, is(equalTo(CONTENT)));
}

@Test
void shouldEncodeEmptyContent() throws IOException {
// Given / When
byte[] encodedContent = encoding.encode(EMPTY_CONTENT);
// Then
assertThat(encodedContent, is(equalTo(EMPTY_CONTENT_ENCODED)));
}

@Test
void shouldDecodeEmptyContent() throws IOException {
// Given / When
byte[] decodedContent = encoding.decode(EMPTY_CONTENT_ENCODED);
// Then
assertThat(decodedContent, is(equalTo(EMPTY_CONTENT)));
}

@Test
void shouldSkipDecodePlainEmptyContent() throws IOException {
// Given / When
byte[] decodedContent = encoding.decode(EMPTY_CONTENT);
// Then
assertThat(decodedContent, is(equalTo(EMPTY_CONTENT)));
}

@Test
void shouldThrowExceptionWhenDecodingIfNotProperlyEncoded() {
// Given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class HttpEncodingGzipUnitTest {
private static final byte[] CONTENT = "Content 123 ABC".getBytes(StandardCharsets.UTF_8);
private static final byte[] CONTENT_ENCODED = gzip(CONTENT);

private static final byte[] EMPTY_CONTENT = {};
private static final byte[] EMPTY_CONTENT_ENCODED = gzip(EMPTY_CONTENT);

private HttpEncodingGzip encoding = HttpEncodingGzip.getSingleton();

@Test
Expand All @@ -55,6 +58,30 @@ void shouldDecodeContent() throws IOException {
assertThat(decodedContent, is(equalTo(CONTENT)));
}

@Test
void shouldEncodeEmptyContent() throws IOException {
// Given / When
byte[] encodedContent = encoding.encode(EMPTY_CONTENT);
// Then
assertThat(encodedContent, is(equalTo(EMPTY_CONTENT_ENCODED)));
}

@Test
void shouldDecodeEmptyContent() throws IOException {
// Given / When
byte[] decodedContent = encoding.decode(EMPTY_CONTENT_ENCODED);
// Then
assertThat(decodedContent, is(equalTo(EMPTY_CONTENT)));
}

@Test
void shouldSkipDecodePlainEmptyContent() throws IOException {
// Given / When
byte[] decodedContent = encoding.decode(EMPTY_CONTENT);
// Then
assertThat(decodedContent, is(equalTo(EMPTY_CONTENT)));
}

@Test
void shouldThrowExceptionWhenDecodingIfNotProperlyEncoded() {
// Given
Expand Down
Loading