You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2006/12/07 03:51:40 UTC
svn commit: r483329 - in /tomcat/container/tc5.5.x:
catalina/src/share/org/apache/catalina/connector/Request.java
webapps/docs/changelog.xml
Author: markt
Date: Wed Dec 6 18:51:40 2006
New Revision: 483329
URL: http://svn.apache.org/viewvc?view=rev&rev=483329
Log:
Ensure accept-language header conforms to RFC 2616 and ignore it if it doesn't
Modified:
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java
tomcat/container/tc5.5.x/webapps/docs/changelog.xml
Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java?view=diff&rev=483329&r1=483328&r2=483329
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java (original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java Wed Dec 6 18:51:40 2006
@@ -161,6 +161,12 @@
/**
+ * The pattern to match locale language and country components against
+ */
+ protected static String localeRegex = "[a-zA-Z]{1,8}";
+
+
+ /**
* The default Locale if none are specified.
*/
protected static Locale defaultLocale = Locale.getDefault();
@@ -2482,6 +2488,9 @@
String variant = null;
int dash = entry.indexOf('-');
if (dash < 0) {
+ if (!entry.matches(localeRegex)) {
+ continue;
+ }
language = entry;
country = "";
variant = "";
@@ -2495,6 +2504,12 @@
country = cTemp;
} else {
variant = "";
+ }
+ if (!language.matches(localeRegex)) {
+ continue;
+ }
+ if (!country.matches(localeRegex)) {
+ continue;
}
}
Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=483329&r1=483328&r2=483329
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Wed Dec 6 18:51:40 2006
@@ -140,6 +140,10 @@
fails to load. Also remove requirement that custom error report Valves
extend ValveBase. (markt)
</fix>
+ <fix>
+ Ensure Accept-Language headers conform to RFC 2616. Ignore them if
+ they do not. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r483329 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/connector/Request.java
webapps/docs/changelog.xml
Posted by Mark Thomas <ma...@apache.org>.
Remy Maucherat wrote:
> Mark Thomas wrote:
>> Fair point. I'll apply an updated patch shortly.
>
> I can do it too if you don't have time (since I'm the one who's
> suggesting the change).
Since you are offering, I am not going to say no ;)
Cheers,
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r483329 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/connector/Request.java
webapps/docs/changelog.xml
Posted by Remy Maucherat <re...@apache.org>.
Mark Thomas wrote:
> Remy Maucherat wrote:
>> markt@apache.org wrote:
>>> Author: markt
>>> Date: Wed Dec 6 18:51:40 2006
>>> New Revision: 483329
>>>
>>> URL: http://svn.apache.org/viewvc?view=rev&rev=483329
>>> Log:
>>> Ensure accept-language header conforms to RFC 2616 and ignore it if it
>>> doesn't
>> I think a "for" loop with a check for each char in the locale would be
>> better. String.matches recompiles (and matches) a regexp every time, so
>> I think it would be a good idea to avoid it (this whole method is quite
>> bad already, of course).
>
> Fair point. I'll apply an updated patch shortly.
I can do it too if you don't have time (since I'm the one who's
suggesting the change).
Rémy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r483329 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/connector/Request.java
webapps/docs/changelog.xml
Posted by Mark Thomas <ma...@apache.org>.
Remy Maucherat wrote:
> markt@apache.org wrote:
>> Author: markt
>> Date: Wed Dec 6 18:51:40 2006
>> New Revision: 483329
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=483329
>> Log:
>> Ensure accept-language header conforms to RFC 2616 and ignore it if it
>> doesn't
>
> I think a "for" loop with a check for each char in the locale would be
> better. String.matches recompiles (and matches) a regexp every time, so
> I think it would be a good idea to avoid it (this whole method is quite
> bad already, of course).
Fair point. I'll apply an updated patch shortly.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r483329 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/connector/Request.java
webapps/docs/changelog.xml
Posted by Remy Maucherat <re...@apache.org>.
markt@apache.org wrote:
> Author: markt
> Date: Wed Dec 6 18:51:40 2006
> New Revision: 483329
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=483329
> Log:
> Ensure accept-language header conforms to RFC 2616 and ignore it if it doesn't
>
> Modified:
> tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java
> tomcat/container/tc5.5.x/webapps/docs/changelog.xml
>
> Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java
> URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java?view=diff&rev=483329&r1=483328&r2=483329
> ==============================================================================
> --- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java (original)
> +++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Request.java Wed Dec 6 18:51:40 2006
> @@ -161,6 +161,12 @@
>
>
> /**
> + * The pattern to match locale language and country components against
> + */
> + protected static String localeRegex = "[a-zA-Z]{1,8}";
> +
> +
> + /**
> * The default Locale if none are specified.
> */
> protected static Locale defaultLocale = Locale.getDefault();
> @@ -2482,6 +2488,9 @@
> String variant = null;
> int dash = entry.indexOf('-');
> if (dash < 0) {
> + if (!entry.matches(localeRegex)) {
> + continue;
> + }
> language = entry;
> country = "";
> variant = "";
> @@ -2495,6 +2504,12 @@
> country = cTemp;
> } else {
> variant = "";
> + }
> + if (!language.matches(localeRegex)) {
> + continue;
> + }
> + if (!country.matches(localeRegex)) {
> + continue;
I think a "for" loop with a check for each char in the locale would be
better. String.matches recompiles (and matches) a regexp every time, so
I think it would be a good idea to avoid it (this whole method is quite
bad already, of course).
Rémy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org