Changeset 7748


Ignore:
Timestamp:
Sep 26, 2019, 8:47:40 AM (2 years ago)
Author:
Nicklas Nordborg
Message:

References #2180: Replace "UTF-8" with StandardCharsets?.UTF_8

Fixing changes made in BASE 3.15.1.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/util/HTML.java

    r7738 r7748  
    2323package net.sf.basedb.clients.web.util;
    2424
    25 import java.io.UnsupportedEncodingException;
    2625import java.net.URLEncoder;
    27 import java.util.regex.*;
     26import java.nio.charset.StandardCharsets;
     27import java.util.regex.Matcher;
     28import java.util.regex.Pattern;
    2829
    2930import net.sf.basedb.util.EmailUtil;
     
    348349  {
    349350    if (in == null) return "";
    350     try
    351     {
    352       in = URLEncoder.encode(in, "UTF-8");
    353     }
    354     catch (UnsupportedEncodingException ex)
    355     {}
    356     return in;
     351    return URLEncoder.encode(in, StandardCharsets.UTF_8);
    357352  }
    358353 
  • trunk/src/core/net/sf/basedb/core/Path.java

    r6881 r7748  
    2525import java.io.UnsupportedEncodingException;
    2626import java.net.URLEncoder;
     27import java.nio.charset.Charset;
     28import java.nio.charset.StandardCharsets;
    2729import java.util.regex.Pattern;
    2830
     
    293295    @param enc The encoding to use. UTF-8 is used is this is null.
    294296    @return The encoded URL-string.
    295       @throws UnsupportedEncodingException If the give encoding is not supported
    296297      @since 2.11.1
    297298   */
    298299  public String toURLString(String enc)
    299     throws UnsupportedEncodingException
    300300  {
    301301    StringBuilder sb = new StringBuilder();
    302     enc = (enc == null || enc.length() == 0) ? "UTF-8" : enc;
     302    Charset cs = (enc == null || enc.length() == 0) ? StandardCharsets.UTF_8 : Charset.forName(enc);
    303303    if (userlogin != null)
    304304    {
    305       sb.append("~").append(URLEncoder.encode(userlogin, enc));
     305      sb.append("~").append(URLEncoder.encode(userlogin, cs));
    306306    }
    307307    for (String directory : directories)
    308308    {
    309       sb.append("/").append(URLEncoder.encode(directory, enc));
     309      sb.append("/").append(URLEncoder.encode(directory, cs));
    310310    }
    311311    if (filename != null && getType() == Type.FILE)
    312312    {
    313       sb.append("/").append(URLEncoder.encode(filename, enc));
     313      sb.append("/").append(URLEncoder.encode(filename, cs));
    314314    }
    315315    if (sb.length() == 0) sb.append("/"); // For the root directory
Note: See TracChangeset for help on using the changeset viewer.