On 12/02/2015 01:16, Konstantin Kolinko wrote:
> 2015-02-11 22:18 GMT+03:00  <ma...@apache.org>:
>> Author: markt
>> Date: Wed Feb 11 19:18:46 2015
>> New Revision: 1659043
>>
>> URL: http://svn.apache.org/r1659043
>> Log:
>> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57534
>> CORS Filter should only look at media type component of content type
>>
>> Modified:
>>     tomcat/trunk/java/org/apache/catalina/filters/CorsFilter.java
>>     tomcat/trunk/test/org/apache/catalina/filters/TestCorsFilter.java
>>
>> Modified: tomcat/trunk/java/org/apache/catalina/filters/CorsFilter.java
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/filters/CorsFilter.java?rev=1659043&r1=1659042&r2=1659043&view=diff
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/catalina/filters/CorsFilter.java (original)
>> +++ tomcat/trunk/java/org/apache/catalina/filters/CorsFilter.java Wed Feb 11 
>> 19:18:46 2015
>> @@ -639,11 +639,10 @@ public final class CorsFilter implements
>>                      } else if ("GET".equals(method) || 
>> "HEAD".equals(method)) {
>>                          requestType = CORSRequestType.SIMPLE;
>>                      } else if ("POST".equals(method)) {
>> -                        String contentType = request.getContentType();
>> -                        if (contentType != null) {
>> -                            contentType = contentType.toLowerCase().trim();
>> +                        String mediaType = 
>> getMediaType(request.getContentType());
>> +                        if (mediaType != null) {
>>                              if (SIMPLE_HTTP_REQUEST_CONTENT_TYPE_VALUES
>> -                                    .contains(contentType)) {
>> +                                    .contains(mediaType)) {
>>                                  requestType = CORSRequestType.SIMPLE;
>>                              } else {
>>                                  requestType = CORSRequestType.ACTUAL;
>> @@ -662,6 +661,23 @@ public final class CorsFilter implements
>>      }
>>
>>
>> +    /*
>> +     * Return the lower case, trimmed value of the media type from the 
>> content
>> +     * type.
>> +     */
>> +    private String getMediaType(String contentType) {
>> +        if (contentType == null) {
>> +            return null;
>> +        }
>> +        String result = contentType.toLowerCase();
> 
> We usually use  Locale.ENGLISH  in such code.

We do. I'll fix that. Thanks for catching that.

Mark

> 
>> +        int firstSemiColonIndex = result.indexOf(';');
>> +        if (firstSemiColonIndex > -1) {
>> +            result = result.substring(0, firstSemiColonIndex);
>> +        }
>> +        result = result.trim();
>> +        return result;
>> +    }
>> +
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to