Changeset 7482


Ignore:
Timestamp:
May 14, 2018, 8:13:12 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2116: The "Character set" of a file seems to be reverted to the default "ISO-8859-1" in some cases

The problem was that the last used file is auto-selected by the plug-in configuration but it didn't handle the case when the files character set is different than the default character set. This has been fixed by storing the character set in the current context under the key last-file-charset.

The same problem was also present when the auto-detect file format function was used.

Location:
branches/3.12-stable/www/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.12-stable/www/common/import/index.jsp

    r7201 r7482  
    189189
    190190    cc.setObject("auto-detected-file", f);
     191    cc.setObject("last-file-charset", charset);
    191192    int matches = plugins.size();
    192193    if (matches == 0)
  • branches/3.12-stable/www/common/plugin/configure.jsp

    r7030 r7482  
    9999    }
    100100  }
     101 
     102  // Special handling for "charset" parameter to make it match the auto-selected file
     103  if (currentContext != null && Parameters.CHARSET_PARAMETER.equals(pp.getName()))
     104  {
     105    Object charset = currentContext.getObject("last-file-charset");
     106    if (charset != null) values = Collections.singletonList(charset);
     107  }
     108 
    101109  // Then, we check the parameters default value
    102110  if ((values == null || values.size() == 0) && pp.getDefaultValue() != null)
     
    123131        try
    124132        {
    125           values.add(File.getById(dc, cc.getId()).getPath().toString());
     133          File file = File.getById(dc, cc.getId());
     134          values.add(file.getPath().toString());
     135          if (currentContext != null && file.getCharacterSet() != null)
     136          {
     137            currentContext.setObject("last-file-charset", file.getCharacterSet());
     138          }
    126139        }
    127140        catch (Throwable t)
Note: See TracChangeset for help on using the changeset viewer.