mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Fix StringIndexOutOfBoundsException (#15319)
Fixes #15318 Reverts #14402 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
7f6502d769
commit
e60446d305
@ -43,6 +43,7 @@ import javax.net.ssl.SSLSocketFactory;
|
|||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openhab.binding.digitalstrom.internal.lib.config.Config;
|
import org.openhab.binding.digitalstrom.internal.lib.config.Config;
|
||||||
import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
|
import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
|
||||||
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.HttpTransport;
|
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.HttpTransport;
|
||||||
@ -333,8 +334,7 @@ public class HttpTransportImpl implements HttpTransport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkNeededSessionToken(String request) {
|
private boolean checkNeededSessionToken(String request) {
|
||||||
String requestFirstPart = request.substring(0, request.indexOf("?"));
|
String functionName = StringUtils.substringAfterLast(StringUtils.substringBefore(request, "?"), "/");
|
||||||
String functionName = requestFirstPart.substring(requestFirstPart.lastIndexOf("/") + 1);
|
|
||||||
return !DsAPIImpl.METHODS_MUST_NOT_BE_LOGGED_IN.contains(functionName);
|
return !DsAPIImpl.METHODS_MUST_NOT_BE_LOGGED_IN.contains(functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,10 +347,8 @@ public class HttpTransportImpl implements HttpTransport {
|
|||||||
correctedRequest = correctedRequest + "?" + ParameterKeys.TOKEN + "=" + sessionToken;
|
correctedRequest = correctedRequest + "?" + ParameterKeys.TOKEN + "=" + sessionToken;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String strippedRequest = correctedRequest
|
correctedRequest = StringUtils.replaceOnce(correctedRequest, StringUtils.substringBefore(
|
||||||
.substring(correctedRequest.indexOf(ParameterKeys.TOKEN + "=") + ParameterKeys.TOKEN.length() + 1);
|
StringUtils.substringAfter(correctedRequest, ParameterKeys.TOKEN + "="), "&"), sessionToken);
|
||||||
strippedRequest = strippedRequest.substring(0, strippedRequest.lastIndexOf("&"));
|
|
||||||
correctedRequest = correctedRequest.replaceFirst(strippedRequest, sessionToken);
|
|
||||||
}
|
}
|
||||||
return correctedRequest;
|
return correctedRequest;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user