From 3d71a5404b9b007f8ce6dcbda83aeb597cf010ff Mon Sep 17 00:00:00 2001
From: zzz <zzz@i2pmail.org>
Date: Fri, 3 Feb 2023 07:28:42 -0500
Subject: [PATCH] Util: Fix check for illegal chars in storeProps()

ref: http://zzz.i2p/topics/3576
---
 core/java/src/net/i2p/data/DataHelper.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java
index 4dae9a0cd4..0177096f85 100644
--- a/core/java/src/net/i2p/data/DataHelper.java
+++ b/core/java/src/net/i2p/data/DataHelper.java
@@ -110,8 +110,8 @@ public class DataHelper {
         }
     }
 
-    private static final Pattern ILLEGAL_KEY =  Pattern.compile("[#=\r\n;]");
-    private static final Pattern ILLEGAL_VALUE =  Pattern.compile("[#\r\n]");
+    private static final Pattern ILLEGAL_KEY =  Pattern.compile("[#=\\r\\n;]");
+    private static final Pattern ILLEGAL_VALUE =  Pattern.compile("[#\\r\\n]");
 
     /**
      *  The default formatting for date/time, current locale, local time zone
@@ -535,13 +535,13 @@ public class DataHelper {
             for (Map.Entry<Object, Object> entry : props.entrySet()) {
                 String name = (String) entry.getKey();
                 String val = (String) entry.getValue();
-                if (ILLEGAL_KEY.matcher(name).matches()) {
+                if (ILLEGAL_KEY.matcher(name).find()) {
                     if (iae == null)
                         iae = new IllegalArgumentException("Invalid character (one of \"#;=\\r\\n\") in key: \"" +
                                                            name + "\" = \"" + val + '\"');
                     continue;
                 }
-                if (ILLEGAL_VALUE.matcher(val).matches()) {
+                if (ILLEGAL_VALUE.matcher(val).find()) {
                     if (iae == null)
                         iae = new IllegalArgumentException("Invalid character (one of \"#\\r\\n\") in value: \"" +
                                                            name + "\" = \"" + val + '\"');
-- 
GitLab