Skip to content

Commit

Permalink
* buckets/apr_brigade.c (apr_brigade_split_line): After finding an LF,
Browse files Browse the repository at this point in the history
  only split the bucket if the LF is not the last character in the
  data.

* test/testbuckets.c (test_splitline_exactly): New test.

PR: 64273
Github: closes #53
Submitted by: Barnim Dzwillo <dzwillo strato.de>, jorton


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1915658 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
notroj committed Feb 8, 2024
1 parent 8e68a77 commit 16cf73e
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/testbuckets.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ static apr_bucket_brigade *make_simple_brigade(apr_bucket_alloc_t *ba,
e = apr_bucket_transient_create(first, strlen(first), ba);
APR_BRIGADE_INSERT_TAIL(bb, e);

e = apr_bucket_transient_create(second, strlen(second), ba);
APR_BRIGADE_INSERT_TAIL(bb, e);
if (second) {
e = apr_bucket_transient_create(second, strlen(second), ba);
APR_BRIGADE_INSERT_TAIL(bb, e);
}

return bb;
}
Expand Down Expand Up @@ -214,6 +216,29 @@ static void test_splitline(abts_case *tc, void *data)
apr_bucket_alloc_destroy(ba);
}

static void test_splitline_exactly(abts_case *tc, void *data)
{
apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
apr_bucket_brigade *bin, *bout;

bin = make_simple_brigade(ba, "foo bar.\n", NULL);
bout = apr_brigade_create(p, ba);

APR_ASSERT_SUCCESS(tc, "split line",
apr_brigade_split_line(bout, bin,
APR_BLOCK_READ, 100));

ABTS_INT_EQUAL(tc, 1, count_buckets(bout));
ABTS_INT_EQUAL(tc, 0, count_buckets(bin));

flatten_match(tc, "output brigade", bout, "foo bar.\n");

apr_brigade_destroy(bout);
apr_brigade_destroy(bin);
apr_bucket_alloc_destroy(ba);
}


static void test_splitline_eos(abts_case *tc, void *data)
{
apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
Expand Down Expand Up @@ -642,6 +667,7 @@ abts_suite *testbuckets(abts_suite *suite)
abts_run_test(suite, test_split, NULL);
abts_run_test(suite, test_bwrite, NULL);
abts_run_test(suite, test_splitline, NULL);
abts_run_test(suite, test_splitline_exactly, NULL);
abts_run_test(suite, test_splitline_eos, NULL);
abts_run_test(suite, test_splitboundary, NULL);
abts_run_test(suite, test_splits, NULL);
Expand Down

0 comments on commit 16cf73e

Please sign in to comment.