maskit commented on a change in pull request #2888: PIP-25: Token based 
authentication
URL: https://github.com/apache/pulsar/pull/2888#discussion_r236655481
 
 

 ##########
 File path: 
pulsar-common/src/main/java/org/apache/pulsar/client/api/url/DataURLStreamHandler.java
 ##########
 @@ -57,20 +60,23 @@ public void connect() throws IOException {
             if (this.uri == null) {
                 throw new IOException();
             }
-            Pattern pattern = Pattern.compile(
-                    
"(?<mimeType>.+?)(;(?<charset>charset=.+?))?(;(?<base64>base64?))?,(?<data>.+)",
 Pattern.DOTALL);
+
             Matcher matcher = 
pattern.matcher(this.uri.getSchemeSpecificPart());
             if (matcher.matches()) {
                 this.contentType = matcher.group("mimeType");
-                String charset = matcher.group("charset");
-                if (charset == null) {
-                    charset = "US-ASCII";
+                if (contentType == null) {
+                    this.contentType = "application/data";
                 }
+
+                for (int i =0; i < matcher.groupCount(); i++) {
+                    System.out.println("Group: " + matcher.group(i));
+                }
+
                 if (matcher.group("base64") == null) {
                     // Support Urlencode but not decode here because already 
decoded by URI class.
-                    this.data = new String(matcher.group("data").getBytes(), 
charset);
+                    this.data = matcher.group("data").getBytes();
 
 Review comment:
   Well, this is probably equivalent to the original code, so this change is 
fine.
   
   However, I realized that the both code have the same issue. Because we drop 
charset information here, users cannot read the data as a string with the 
specified charset. I think we should stop parsing parameters in mimetype and 
return the whole mimetype part as content-type.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to