Skip to content

Commit

Permalink
Extend Asn1Parser to parse UTF8Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-o authored and markt-asf committed May 3, 2024
1 parent 21e4ac2 commit af92d6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions java/org/apache/tomcat/util/buf/Asn1Parser.java
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -149,6 +151,12 @@ public byte[] parseOIDAsBytes() {
}


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);
}
Expand Down
3 changes: 3 additions & 0 deletions webapps/docs/changelog.xml
Expand Up @@ -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">
Expand Down

0 comments on commit af92d6e

Please sign in to comment.