Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MimeParser parses closing boundary as normal boundary #3967

Closed
romain-grecourt opened this issue Mar 16, 2022 · 0 comments · Fixed by #3968
Closed

MimeParser parses closing boundary as normal boundary #3967

romain-grecourt opened this issue Mar 16, 2022 · 0 comments · Fixed by #3968
Assignees
Labels
2.x Issues for 2.x version branch 3.x Issues for 3.x version branch bug Something isn't working SE
Milestone

Comments

@romain-grecourt
Copy link
Contributor

When the closing delimiter of the closing boundary is delivered in a different chunk, MimeParser detects it as a normal boundary causing a parsing exception No closing MIME boundary.

Here is a simple test case to demonstrate the issue:

    @Test
    public void testClosingBoundaryAcrossChunks3() {
        String boundary = "boundary";
        final byte[] chunk1 = ("--" + boundary + "\n"
                + "Content-Id: part1\n"
                + "\n"
                + "this-is-the-body-of-part1\n"
                + "--" + boundary).getBytes();
        final byte[] chunk2 = "--".getBytes();

        List<MimePart> parts = parse(boundary, List.of(chunk1, chunk2)).parts;
        assertThat(parts.size(), is(equalTo(1)));

        MimePart part1 = parts.get(0);
        assertThat(part1.headers.size(), is(equalTo(1)));
        assertThat(part1.headers.get("Content-Id"), hasItems("part1"));
        assertThat(part1.content, is(notNullValue()));
        assertThat(new String(part1.content), is(equalTo("this-is-the-body-of-part1")));
    }
@romain-grecourt romain-grecourt added bug Something isn't working SE 2.x Issues for 2.x version branch 3.x Issues for 3.x version branch labels Mar 16, 2022
@romain-grecourt romain-grecourt added this to the 2.4.3 milestone Mar 16, 2022
@romain-grecourt romain-grecourt self-assigned this Mar 16, 2022
romain-grecourt added a commit to romain-grecourt/helidon that referenced this issue Mar 16, 2022
…elidon-io#3968)

I.e. a boundary located at the end of the current buffer that could be a "closing" boundary.

Fixes helidon-io#3967
romain-grecourt added a commit that referenced this issue Mar 17, 2022
…3968) (#3971)

I.e. a boundary located at the end of the current buffer that could be a "closing" boundary.

Fixes #3967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Issues for 2.x version branch 3.x Issues for 3.x version branch bug Something isn't working SE
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant