Skip to content

Commit

Permalink
[Android] fix URL encoding for Android API client (swagger-api#3992)
Browse files Browse the repository at this point in the history
* fix url encoding for android

* add exception handling for url encoding in android
  • Loading branch information
wing328 committed Oct 14, 2016
1 parent 544b352 commit 98e22a8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import org.apache.http.params.*;
import org.apache.http.util.EntityUtils;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.URLEncoder;
Expand All @@ -25,8 +27,6 @@ import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
Expand Down Expand Up @@ -207,7 +207,11 @@ public class ApiInvoker {
}

public String escapeString(String str) {
return str;
try {
return URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException e) {
return str;
}
}

public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -232,7 +233,11 @@ public class ApiInvoker {
}

public String escapeString(String str) {
return str;
try {
return URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException e) {
return str;
}
}

public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.apache.http.util.EntityUtils;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.URLEncoder;
Expand All @@ -48,8 +50,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
Expand Down Expand Up @@ -230,7 +230,11 @@ public void addDefaultHeader(String key, String value) {
}

public String escapeString(String str) {
return str;
try {
return URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException e) {
return str;
}
}

public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -246,7 +247,11 @@ public void addDefaultHeader(String key, String value) {
}

public String escapeString(String str) {
return str;
try {
return URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException e) {
return str;
}
}

public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
Expand Down

0 comments on commit 98e22a8

Please sign in to comment.