Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ba951cb

Browse filesBrowse files
Fix hub4j#252: infinite loop because the "hypertext engine" may duplicate '?' generating invalid "https://api.github.com/notifications?all=true&page=2?all=true" instead of "https://api.github.com/notifications?all=true&page=2&all=true". A better fix will be to prevent duplication of parameters ("all=true" in this case).
1 parent dbc79f8 commit ba951cb
Copy full SHA for ba951cb

File tree

Expand file treeCollapse file tree

1 file changed

+12
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-7
lines changed

‎src/main/java/org/kohsuke/github/Requester.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/Requester.java
+12-7Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.Iterator;
4646
import java.util.LinkedHashMap;
4747
import java.util.List;
48+
import java.util.ListIterator;
4849
import java.util.Locale;
4950
import java.util.Map;
5051
import java.util.NoSuchElementException;
@@ -219,15 +220,19 @@ public <T> T to(String tailApiUrl, Class<T> type, String method) throws IOExcept
219220
}
220221

221222
private <T> T _to(String tailApiUrl, Class<T> type, T instance) throws IOException {
222-
while (true) {// loop while API rate limit is hit
223-
if (METHODS_WITHOUT_BODY.contains(method) && !args.isEmpty()) {
224-
StringBuilder qs=new StringBuilder();
225-
for (Entry arg : args) {
226-
qs.append(qs.length()==0 ? '?' : '&');
227-
qs.append(arg.key).append('=').append(URLEncoder.encode(arg.value.toString(),"UTF-8"));
223+
if (METHODS_WITHOUT_BODY.contains(method) && !args.isEmpty()) {
224+
boolean questionMarkFound = tailApiUrl.indexOf('?') != -1;
225+
tailApiUrl += questionMarkFound ? '&' : '?';
226+
for (Iterator<Entry> it = args.listIterator(); it.hasNext();) {
227+
Entry arg = it.next();
228+
tailApiUrl += arg.key + '=' + URLEncoder.encode(arg.value.toString(),"UTF-8");
229+
if (it.hasNext()) {
230+
tailApiUrl += '&';
228231
}
229-
tailApiUrl += qs.toString();
230232
}
233+
}
234+
235+
while (true) {// loop while API rate limit is hit
231236
setupConnection(root.getApiURL(tailApiUrl));
232237

233238
buildRequest();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.