From 7155c5cbea44e2a37c3a20e9a9b4ff65b04dc102 Mon Sep 17 00:00:00 2001 From: stsp Date: Sat, 26 Apr 2008 15:28:17 +0000 Subject: [PATCH] * subversion/libsvn_subr/validate.c (svn_mime_type_validate): Check for illegal characters is now in compliance with RFC 1521. git-svn-id: http://svn.collab.net/repos/svn/trunk@30795 612f8ebc-c883-4be0-9ee0-a4e9ef946e3a --- subversion/libsvn_subr/validate.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/subversion/libsvn_subr/validate.c b/subversion/libsvn_subr/validate.c index 04c188852..cac67aaba 100644 --- a/subversion/libsvn_subr/validate.c +++ b/subversion/libsvn_subr/validate.c @@ -41,6 +41,8 @@ svn_mime_type_validate(const char *mime_type, apr_pool_t *pool) only looking at the media type here. */ const apr_size_t len = strcspn(mime_type, "; "); const char *const slash_pos = strchr(mime_type, '/'); + int i; + const char *tspecials = "()<>@,;:\\\"/[]?="; if (len == 0) return svn_error_createf @@ -52,10 +54,19 @@ svn_mime_type_validate(const char *mime_type, apr_pool_t *pool) (SVN_ERR_BAD_MIME_TYPE, NULL, _("MIME type '%s' does not contain '/'"), mime_type); - if (! apr_isalnum(mime_type[len - 1])) - return svn_error_createf - (SVN_ERR_BAD_MIME_TYPE, NULL, - _("MIME type '%s' ends with non-alphanumeric character"), mime_type); + /* Check the mime type for illegal characters. See RFC 1521. */ + for (i = 0; i < len; i++) + { + if (&mime_type[i] != slash_pos + && (! apr_isascii(mime_type[i]) + || apr_iscntrl(mime_type[i]) + || apr_isspace(mime_type[i]) + || (strchr(tspecials, mime_type[i]) != NULL))) + return svn_error_createf + (SVN_ERR_BAD_MIME_TYPE, NULL, + _("MIME type '%s' contains invalid character '%c'"), + mime_type, mime_type[i]); + } return SVN_NO_ERROR; } -- 2.11.4.GIT