This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new af92d6e3dd Extend Asn1Parser to parse UTF8Strings
af92d6e3dd is described below

commit af92d6e3dda61b633a70741c4b004cb0de5753b8
Author: Michael Osipov <micha...@apache.org>
AuthorDate: Fri May 3 12:39:23 2024 +0200

    Extend Asn1Parser to parse UTF8Strings
---
 java/org/apache/tomcat/util/buf/Asn1Parser.java | 8 ++++++++
 webapps/docs/changelog.xml                      | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/java/org/apache/tomcat/util/buf/Asn1Parser.java 
b/java/org/apache/tomcat/util/buf/Asn1Parser.java
index 1d88b113d4..1282dfc70b 100644
--- a/java/org/apache/tomcat/util/buf/Asn1Parser.java
+++ b/java/org/apache/tomcat/util/buf/Asn1Parser.java
@@ -17,6 +17,7 @@
 package org.apache.tomcat.util.buf;
 
 import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayDeque;
 import java.util.Deque;
 
@@ -36,6 +37,7 @@ public class Asn1Parser {
     public static final int TAG_OCTET_STRING = 0x04;
     public static final int TAG_NULL = 0x05;
     public static final int TAG_OID = 0x06;
+    public static final int TAG_UTF8STRING = 0x0C;
     public static final int TAG_SEQUENCE = 0x30;
     public static final int TAG_ATTRIBUTE_BASE = 0xA0;
 
@@ -149,6 +151,12 @@ public class Asn1Parser {
     }
 
 
+    public String parseUTF8String() {
+        byte[] val = parseBytes(TAG_UTF8STRING);
+        return new String(val, StandardCharsets.UTF_8);
+    }
+
+
     public byte[] parseAttributeAsBytes(int index) {
         return parseBytes(TAG_ATTRIBUTE_BASE + index);
     }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 76fa899f24..70bb21df9d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -149,6 +149,9 @@
       <fix>
         Add periodic checking for WebDAV locks expiration. (remm)
       </fix>
+      <fix>
+        Extend <code>Asn1Parser</code> to parse <code>UTF8String</code>s. 
(michaelo)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to