diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java index 72e182d69..76fe0c4f5 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java @@ -9,6 +9,8 @@ import java.util.Locale; import java.util.Properties; import java.util.Set; import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import net.i2p.app.ClientApp; import net.i2p.app.ClientAppState; @@ -37,6 +39,15 @@ public class ConfigClientsHelper extends HelperBase { public static final String PROP_ENABLE_CLIENT_CHANGE = "routerconsole.enableClientChange"; public static final String PROP_ENABLE_PLUGIN_INSTALL = "routerconsole.enablePluginInstall"; + /** + * simple regex from + * https://stackoverflow.com/questions/8204680/java-regex-email + * not the massive RFC 822 compliant one + * modified so .i2p will work + */ + private static final Pattern VALID_EMAIL_ADDRESS_REGEX = + Pattern.compile("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z2]{2,6}", Pattern.CASE_INSENSITIVE); + public ConfigClientsHelper() {} /** @since 0.9.14.1 */ @@ -303,14 +314,8 @@ public class ConfigClientsHelper extends HelperBase { s = stripHTML(appProps, "author"); if (s != null) { String[] authors = DataHelper.split(s, "[,; \r\n\t]"); - String author = null; - for (int i = 0; i < authors.length; i++) { - String a = authors[i]; - if (a.indexOf('@') > 0 && a.indexOf('.') > 0) { - author = a; - break; - } - } + Matcher m = VALID_EMAIL_ADDRESS_REGEX.matcher(s); + String author = m.find() ? m.group() : null; desc.append("") .append(_t("Author")).append(""); if (author != null)