Skip to content

Commit 3b95fc7

Browse files
committed
On the 'apply-processor' branch: sync with trunk@r1922653.
git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/apply-processor@1922654 13f79535-47bb-0310-9956-ffa450edef68
2 parents 8fcdb0c + 9a22948 commit 3b95fc7

File tree

18 files changed

+615
-264
lines changed

18 files changed

+615
-264
lines changed

.github/workflows/cmake.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,16 @@ jobs:
169169
working-directory: out
170170
run: ctest --output-on-failure --verbose -C Release --parallel 16
171171

172-
- name: Rerun failed tests
173-
if: ${{ matrix.run_tests && failure() && steps.run_all_tests.conclusion == 'failure' }}
172+
- name: Test shelf2
173+
if: matrix.run_tests
174+
working-directory: out
175+
env:
176+
SVN_EXPERIMENTAL_COMMANDS: shelf2
177+
run: ctest -R shelf2 --verbose -C Release
178+
179+
- name: Test shelf3
180+
if: matrix.run_tests
174181
working-directory: out
175-
run: ctest --output-on-failure --verbose -C Release --rerun-failed
182+
env:
183+
SVN_EXPERIMENTAL_COMMANDS: shelf3
184+
run: ctest -R shelf3 --verbose -C Release

subversion/bindings/swig/include/svn_types.swg

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ svn_ ## TYPE ## _swig_rb_closed(VALUE self)
546546
%typemap(ret) svn_error_t *
547547
{
548548
if (TYPE(*svn_presult) == T_ARRAY) {
549-
switch (rb_array_len(*svn_presult)) {
549+
switch (RARRAY_LEN(*svn_presult)) {
550550
case 0:
551551
*svn_presult = Qnil;
552552
break;

subversion/include/private/svn_client_private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ svn_client__get_diff_writer_svn(
375375
svn_boolean_t ignore_content_type,
376376
svn_boolean_t ignore_properties,
377377
svn_boolean_t properties_only,
378-
svn_boolean_t pretty_print_mergeinfo,
379378
svn_boolean_t use_git_diff_format,
379+
svn_boolean_t pretty_print_mergeinfo,
380380
const char *header_encoding,
381381
svn_stream_t *outstream,
382382
svn_stream_t *errstream,

subversion/include/private/svn_repos_private.h

+8
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@ svn_repos__get_dump_editor(const svn_delta_editor_t **editor,
390390
const char *update_anchor_relpath,
391391
apr_pool_t *pool);
392392

393+
/* Validate that the given PATH is a valid pathname that can be stored in
394+
* a Subversion repository, according to the name constraints used by the
395+
* svn_repos_* layer.
396+
*/
397+
svn_error_t *
398+
svn_repos__validate_new_path(const char *path,
399+
apr_pool_t *scratch_pool);
400+
393401
#ifdef __cplusplus
394402
}
395403
#endif /* __cplusplus */

subversion/include/svn_xml.h

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include "svn_types.h"
3535
#include "svn_string.h"
36+
#include "svn_io.h" /* for svn_stream_t */
3637

3738
#ifdef __cplusplus
3839
extern "C" {
@@ -191,6 +192,23 @@ void
191192
svn_xml_free_parser(svn_xml_parser_t *svn_parser);
192193

193194

195+
/** Create a stream that wraps the XML parser described at @a parser.
196+
*
197+
* The stream produced will implement 'write' and 'close' methods. It
198+
* will push the data to the parser on write operation, and flush it on
199+
* close.
200+
*
201+
* This stream can be used as a generic writable stream, so the callers
202+
* may pipe any data there, for example, using the svn_stream_copy3
203+
* function, in case of a file source.
204+
*
205+
* @since New in 1.15.
206+
*/
207+
svn_stream_t *
208+
svn_xml_make_parse_stream(svn_xml_parser_t *parser,
209+
apr_pool_t *result_pool);
210+
211+
194212
/** Push @a len bytes of xml data in @a buf at @a svn_parser.
195213
*
196214
* If this is the final push, @a is_final must be set.

subversion/libsvn_repos/commit.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@ add_file_or_directory(const char *path,
308308
svn_boolean_t was_copied = FALSE;
309309
const char *full_path, *canonicalized_path;
310310

311-
/* Reject paths which contain control characters (related to issue #4340). */
312-
SVN_ERR(svn_path_check_valid(path, pool));
311+
SVN_ERR(svn_repos__validate_new_path(path, pool));
313312

314313
SVN_ERR(svn_relpath_canonicalize_safe(&canonicalized_path, NULL, path,
315314
pool, pool));

subversion/libsvn_repos/repos.c

+10
Original file line numberDiff line numberDiff line change
@@ -2092,3 +2092,13 @@ svn_repos__fs_type(const char **fs_type,
20922092
svn_dirent_join(repos_path, SVN_REPOS__DB_DIR, pool),
20932093
pool);
20942094
}
2095+
2096+
svn_error_t *
2097+
svn_repos__validate_new_path(const char *path,
2098+
apr_pool_t *scratch_pool)
2099+
{
2100+
/* Reject paths which contain control characters (related to issue #4340). */
2101+
SVN_ERR(svn_path_check_valid(path, scratch_pool));
2102+
2103+
return SVN_NO_ERROR;
2104+
}

subversion/libsvn_subr/xml.c

-247
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
#include "svn_pools.h"
3232
#include "svn_xml.h"
3333
#include "svn_error.h"
34-
#include "svn_ctype.h"
3534

36-
#include "private/svn_utf_private.h"
3735
#include "private/svn_subr_private.h"
3836

3937
#ifdef SVN_HAVE_OLD_EXPAT
@@ -98,251 +96,6 @@ struct svn_xml_parser_t
9896

9997
};
10098

101-
102-
/*** XML character validation ***/
103-
104-
svn_boolean_t
105-
svn_xml_is_xml_safe(const char *data, apr_size_t len)
106-
{
107-
const char *end = data + len;
108-
const char *p;
109-
110-
if (! svn_utf__is_valid(data, len))
111-
return FALSE;
112-
113-
for (p = data; p < end; p++)
114-
{
115-
unsigned char c = *p;
116-
117-
if (svn_ctype_iscntrl(c))
118-
{
119-
if ((c != SVN_CTYPE_ASCII_TAB)
120-
&& (c != SVN_CTYPE_ASCII_LINEFEED)
121-
&& (c != SVN_CTYPE_ASCII_CARRIAGERETURN)
122-
&& (c != SVN_CTYPE_ASCII_DELETE))
123-
return FALSE;
124-
}
125-
}
126-
return TRUE;
127-
}
128-
129-
130-
131-
132-
133-
/*** XML escaping. ***/
134-
135-
/* ### ...?
136-
*
137-
* If *OUTSTR is @c NULL, set *OUTSTR to a new stringbuf allocated
138-
* in POOL, else append to the existing stringbuf there.
139-
*/
140-
static void
141-
xml_escape_cdata(svn_stringbuf_t **outstr,
142-
const char *data,
143-
apr_size_t len,
144-
apr_pool_t *pool)
145-
{
146-
const char *end = data + len;
147-
const char *p = data, *q;
148-
149-
if (*outstr == NULL)
150-
*outstr = svn_stringbuf_create_empty(pool);
151-
152-
while (1)
153-
{
154-
/* Find a character which needs to be quoted and append bytes up
155-
to that point. Strictly speaking, '>' only needs to be
156-
quoted if it follows "]]", but it's easier to quote it all
157-
the time.
158-
159-
So, why are we escaping '\r' here? Well, according to the
160-
XML spec, '\r\n' gets converted to '\n' during XML parsing.
161-
Also, any '\r' not followed by '\n' is converted to '\n'. By
162-
golly, if we say we want to escape a '\r', we want to make
163-
sure it remains a '\r'! */
164-
q = p;
165-
while (q < end && *q != '&' && *q != '<' && *q != '>' && *q != '\r')
166-
q++;
167-
svn_stringbuf_appendbytes(*outstr, p, q - p);
168-
169-
/* We may already be a winner. */
170-
if (q == end)
171-
break;
172-
173-
/* Append the entity reference for the character. */
174-
if (*q == '&')
175-
svn_stringbuf_appendcstr(*outstr, "&amp;");
176-
else if (*q == '<')
177-
svn_stringbuf_appendcstr(*outstr, "&lt;");
178-
else if (*q == '>')
179-
svn_stringbuf_appendcstr(*outstr, "&gt;");
180-
else if (*q == '\r')
181-
svn_stringbuf_appendcstr(*outstr, "&#13;");
182-
183-
p = q + 1;
184-
}
185-
}
186-
187-
/* Essentially the same as xml_escape_cdata, with the addition of
188-
whitespace and quote characters. */
189-
static void
190-
xml_escape_attr(svn_stringbuf_t **outstr,
191-
const char *data,
192-
apr_size_t len,
193-
apr_pool_t *pool)
194-
{
195-
const char *end = data + len;
196-
const char *p = data, *q;
197-
198-
if (*outstr == NULL)
199-
*outstr = svn_stringbuf_create_ensure(len, pool);
200-
201-
while (1)
202-
{
203-
/* Find a character which needs to be quoted and append bytes up
204-
to that point. */
205-
q = p;
206-
while (q < end && *q != '&' && *q != '<' && *q != '>'
207-
&& *q != '"' && *q != '\'' && *q != '\r'
208-
&& *q != '\n' && *q != '\t')
209-
q++;
210-
svn_stringbuf_appendbytes(*outstr, p, q - p);
211-
212-
/* We may already be a winner. */
213-
if (q == end)
214-
break;
215-
216-
/* Append the entity reference for the character. */
217-
if (*q == '&')
218-
svn_stringbuf_appendcstr(*outstr, "&amp;");
219-
else if (*q == '<')
220-
svn_stringbuf_appendcstr(*outstr, "&lt;");
221-
else if (*q == '>')
222-
svn_stringbuf_appendcstr(*outstr, "&gt;");
223-
else if (*q == '"')
224-
svn_stringbuf_appendcstr(*outstr, "&quot;");
225-
else if (*q == '\'')
226-
svn_stringbuf_appendcstr(*outstr, "&apos;");
227-
else if (*q == '\r')
228-
svn_stringbuf_appendcstr(*outstr, "&#13;");
229-
else if (*q == '\n')
230-
svn_stringbuf_appendcstr(*outstr, "&#10;");
231-
else if (*q == '\t')
232-
svn_stringbuf_appendcstr(*outstr, "&#9;");
233-
234-
p = q + 1;
235-
}
236-
}
237-
238-
239-
void
240-
svn_xml_escape_cdata_stringbuf(svn_stringbuf_t **outstr,
241-
const svn_stringbuf_t *string,
242-
apr_pool_t *pool)
243-
{
244-
xml_escape_cdata(outstr, string->data, string->len, pool);
245-
}
246-
247-
248-
void
249-
svn_xml_escape_cdata_string(svn_stringbuf_t **outstr,
250-
const svn_string_t *string,
251-
apr_pool_t *pool)
252-
{
253-
xml_escape_cdata(outstr, string->data, string->len, pool);
254-
}
255-
256-
257-
void
258-
svn_xml_escape_cdata_cstring(svn_stringbuf_t **outstr,
259-
const char *string,
260-
apr_pool_t *pool)
261-
{
262-
xml_escape_cdata(outstr, string, (apr_size_t) strlen(string), pool);
263-
}
264-
265-
266-
void
267-
svn_xml_escape_attr_stringbuf(svn_stringbuf_t **outstr,
268-
const svn_stringbuf_t *string,
269-
apr_pool_t *pool)
270-
{
271-
xml_escape_attr(outstr, string->data, string->len, pool);
272-
}
273-
274-
275-
void
276-
svn_xml_escape_attr_string(svn_stringbuf_t **outstr,
277-
const svn_string_t *string,
278-
apr_pool_t *pool)
279-
{
280-
xml_escape_attr(outstr, string->data, string->len, pool);
281-
}
282-
283-
284-
void
285-
svn_xml_escape_attr_cstring(svn_stringbuf_t **outstr,
286-
const char *string,
287-
apr_pool_t *pool)
288-
{
289-
xml_escape_attr(outstr, string, (apr_size_t) strlen(string), pool);
290-
}
291-
292-
293-
const char *
294-
svn_xml_fuzzy_escape(const char *string, apr_pool_t *pool)
295-
{
296-
const char *end = string + strlen(string);
297-
const char *p = string, *q;
298-
svn_stringbuf_t *outstr;
299-
char escaped_char[6]; /* ? \ u u u \0 */
300-
301-
for (q = p; q < end; q++)
302-
{
303-
if (svn_ctype_iscntrl(*q)
304-
&& ! ((*q == '\n') || (*q == '\r') || (*q == '\t')))
305-
break;
306-
}
307-
308-
/* Return original string if no unsafe characters found. */
309-
if (q == end)
310-
return string;
311-
312-
outstr = svn_stringbuf_create_empty(pool);
313-
while (1)
314-
{
315-
q = p;
316-
317-
/* Traverse till either unsafe character or eos. */
318-
while ((q < end)
319-
&& ((! svn_ctype_iscntrl(*q))
320-
|| (*q == '\n') || (*q == '\r') || (*q == '\t')))
321-
q++;
322-
323-
/* copy chunk before marker */
324-
svn_stringbuf_appendbytes(outstr, p, q - p);
325-
326-
if (q == end)
327-
break;
328-
329-
/* Append an escaped version of the unsafe character.
330-
331-
### This format was chosen for consistency with
332-
### svn_utf__cstring_from_utf8_fuzzy(). The two functions
333-
### should probably share code, even though they escape
334-
### different characters.
335-
*/
336-
apr_snprintf(escaped_char, sizeof(escaped_char), "?\\%03u",
337-
(unsigned char) *q);
338-
svn_stringbuf_appendcstr(outstr, escaped_char);
339-
340-
p = q + 1;
341-
}
342-
343-
return outstr->data;
344-
}
345-
34699

347100
/*** Map from the Expat callback types to the SVN XML types. ***/
348101

0 commit comments

Comments
 (0)