You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/09/19 17:09:00 UTC
svn commit: r290181 -
/directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Author: elecharny
Date: Mon Sep 19 08:08:51 2005
New Revision: 290181
URL: http://svn.apache.org/viewcvs?rev=290181&view=rev
Log:
Fixed a potiential error in encode(ByteBuffer, String) : the
String.getBytes() was called, using the defalut platform encoding
instead of UTF-8.
Thanks to Jérôme baumgarten for the repport !
Modified:
directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Modified: directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
URL: http://svn.apache.org/viewcvs/directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java?rev=290181&r1=290180&r2=290181&view=diff
==============================================================================
--- directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java (original)
+++ directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java Mon Sep 19 08:08:51 2005
@@ -23,6 +23,7 @@
import org.apache.asn1new.util.StringUtils;
import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
@@ -251,7 +252,16 @@
try
{
buffer.put( UniversalTag.OCTET_STRING_TAG );
- byte[] value = string.getBytes();
+ byte[] value = null;
+
+ try
+ {
+ value = string.getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new EncoderException("The Value encoding is not UTF-8");
+ }
buffer.put( Length.getBytes( value.length ) );