Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-5422

I18nInterceptor and invalid locale

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 6.3.0
    • 6.6.0
    • Core Interceptors
    • None

    Description

      Exception if locale contains trimable characters:

       

      Eg Request: 

      request_locale=de%0A

       

      Code from I18nInterceptor line 187:

       

      if (localeProvider.isValidLocaleString(localeStr)) {
      locale = LocaleUtils.toLocale(localeStr);
      }

       

      isValidLocaleString returns true because localeStr is trimmed inside function (
      locale = LocaleUtils.toLocale(StringUtils.trimToNull(localeStr)) )
       
      but LocaleUtils.toLocale(localeStr) will throw an exception afterwards.
       

       

       

       
      java.lang.IllegalArgumentException: Invalid locale format: de
              at org.apache.commons.lang3.LocaleUtils.parseLocale(LocaleUtils.java:268) ~[org.apache.commons-commons-lang3-3.12.0-.jar:3.12.0]
              at org.apache.commons.lang3.LocaleUtils.toLocale(LocaleUtils.java:348) ~[org.apache.commons-commons-lang3-3.12.0-.jar:3.12.0]
              at org.apache.struts2.interceptor.I18nInterceptor.getLocaleFromParam(I18nInterceptor.java:188) ~[org.apache.struts-struts2-core-6.3.0.2-.jar:6.3.0.2]
              at org.apache.struts2.interceptor.I18nInterceptor$SessionLocaleHandler.find(I18nInterceptor.java:321) ~[org.apache.struts-struts2-core-6.3.0.2-.jar:6.3.0.2]
      

       

      Attachments

        Issue Links

          Activity

            People

              lukaszlenart Lukasz Lenart
              asachs Andreas Sachs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m