You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pl...@apache.org on 2016/01/07 04:40:39 UTC

directory-kerby git commit: DIRKRB-522 Krb5Parser parse error. Contributed by Yan.

Repository: directory-kerby
Updated Branches:
  refs/heads/trunk 0047ebd06 -> 0fa065fb8


DIRKRB-522 Krb5Parser parse error. Contributed by Yan.


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/0fa065fb
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/0fa065fb
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/0fa065fb

Branch: refs/heads/trunk
Commit: 0fa065fb8080a2cc1fddfaa9b8ca62b8d1efc8d9
Parents: 0047ebd
Author: plusplusjiajia <ji...@intel.com>
Authored: Thu Jan 7 11:47:26 2016 +0800
Committer: plusplusjiajia <ji...@intel.com>
Committed: Thu Jan 7 11:47:26 2016 +0800

----------------------------------------------------------------------
 .../org/apache/kerby/kerberos/kerb/common/Krb5Parser.java   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0fa065fb/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/Krb5Parser.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/Krb5Parser.java b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/Krb5Parser.java
index f886b2d..ac9bf92 100644
--- a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/Krb5Parser.java
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/Krb5Parser.java
@@ -24,6 +24,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -54,7 +55,8 @@ public class Krb5Parser {
      * @throws IOException e
      */
     public void load() throws IOException {
-        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(krb5conf)));
+        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(krb5conf),
+                StandardCharsets.UTF_8));
         items = new HashMap<String, Object>();
 
         String originLine = br.readLine();
@@ -144,9 +146,10 @@ public class Krb5Parser {
         if (line == null) {
             return line;
         }
-        if (line.startsWith("[") || line.startsWith("#")) {
+        if (line.startsWith("[")) {
             return line;
         }
+
         if (line.startsWith("}")) {
             line = br.readLine();
             if (line != null) {
@@ -154,7 +157,7 @@ public class Krb5Parser {
             }
             return line;
         }
-        if (line.length() == 0) {
+        if (line.length() == 0 || line.startsWith("#")) {
             line = br.readLine();
             if (line != null) {
                 line = line.trim();