dromara/Sa-Token · info · SaTokenException

12104

12104

Error message

{cause}

What it means

SaFoxUtil.decoderUrl wraps URLDecoder.decode(url, "UTF-8") and converts UnsupportedEncodingException into SaTokenException code 12104. Like its encode counterpart, UTF-8 is mandated by the Java platform spec, so this branch is effectively unreachable on any standard JVM. Note it does NOT catch IllegalArgumentException, which is what malformed '%' sequences in the input actually raise.

Source

Thrown at sa-token-core/src/main/java/cn/dev33/satoken/util/SaFoxUtil.java:598

	 */
	public static String encodeUrl(String url) {
		try {
			return URLEncoder.encode(url, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			throw new SaTokenException(e).setCode(SaErrorCode.CODE_12103);
		}
	}

	/**
	 * URL解码
	 * @param url see note
	 * @return see note
	 */
	public static String decoderUrl(String url) {
		try {
			return URLDecoder.decode(url, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			throw new SaTokenException(e).setCode(SaErrorCode.CODE_12104);
		}
	}

	/**
	 * 将指定字符串按照逗号分隔符转化为字符串集合
	 * @param str 字符串
	 * @return 分割后的字符串集合
	 */
	public static List<String> convertStringToList(String str) {
		List<String> list = new ArrayList<>();
		if(isEmpty(str)) {
			return list;
		}
		String[] arr = str.split(",");
		for (String s : arr) {
			s = s.trim();
			if(!isEmpty(s)) {
				list.add(s);

View on GitHub (pinned to ac2c7f6e94)

Solutions

  1. Verify JDK vendor/version if this truly fires; otherwise treat as unreachable
  2. If URL decoding fails in practice, look for IllegalArgumentException from invalid '%' sequences and sanitize the input instead
Defensive patterns

Strategy: fallback

Validate before calling

// guard against the *real* decode failure: malformed '%' sequences
if (url != null && url.matches(".*%(?![0-9a-fA-F]{2}).*")) {
    // clean or reject before URLDecoder runs
}

Prevention

When it happens

Trigger: Only a non-conforming runtime lacking UTF-8 could trigger 12104; decoding a malformed encoded string instead throws IllegalArgumentException from URLDecoder, which propagates unwrapped.

Common situations: Never observed in practice; developers searching error code 12104 in logs are usually actually seeing IllegalArgumentException from bad percent-encoding elsewhere in the stack.

Related errors


AI-assisted analysis of dromara/Sa-Token@ac2c7f6e94 (2026-08-14). Data as JSON: /api/errors/709be9ba396ca515. Report an issue: GitHub.