From 86b9c43b8b09be283e707cbb6d56f8e06abb5890 Mon Sep 17 00:00:00 2001 From: yukaidi Date: Fri, 29 May 2026 06:27:51 +0800 Subject: [PATCH] fix: narrow catch exception type in ParserCreate.java Replace 5 instances of `catch (Exception ignored)` with `catch (IllegalStateException ignored)` around matcher.group() calls, since that method only throws IllegalStateException when a named group does not exist. --- .../main/java/cn/qaiu/parser/ParserCreate.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/parser/src/main/java/cn/qaiu/parser/ParserCreate.java b/parser/src/main/java/cn/qaiu/parser/ParserCreate.java index 71f0e13..b1b630a 100644 --- a/parser/src/main/java/cn/qaiu/parser/ParserCreate.java +++ b/parser/src/main/java/cn/qaiu/parser/ParserCreate.java @@ -81,16 +81,16 @@ public class ParserCreate { if (shareKey != null) { shareLinkInfo.setShareKey(shareKey); } - } catch (Exception ignored) {} - + } catch (IllegalStateException ignored) {} + // 提取密码 try { String pwd = matcher.group("PWD"); if (StringUtils.isNotEmpty(pwd)) { shareLinkInfo.setSharePassword(pwd); } - } catch (Exception ignored) {} - + } catch (IllegalStateException ignored) {} + // 设置标准URL if (customParserConfig.getStandardUrlTemplate() != null) { String standardUrl = customParserConfig.getStandardUrlTemplate() @@ -133,7 +133,7 @@ public class ParserCreate { shareLinkInfo.setSharePassword(pwd); } standardUrl = standardUrl.replace("{pwd}", pwd); - } catch (Exception ignored) {} + } catch (IllegalStateException ignored) {} shareLinkInfo.setShareUrl(shareUrl); shareLinkInfo.setShareKey(shareKey); @@ -266,15 +266,15 @@ public class ParserCreate { if (shareKey != null) { shareLinkInfo.setShareKey(shareKey); } - } catch (Exception ignored) {} - + } catch (IllegalStateException ignored) {} + try { String password = matcher.group("PWD"); if (password != null) { shareLinkInfo.setSharePassword(password); } - } catch (Exception ignored) {} - + } catch (IllegalStateException ignored) {} + // 设置标准URL(如果有模板) if (customConfig.getStandardUrlTemplate() != null) { String standardUrl = customConfig.getStandardUrlTemplate()