mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-15 19:52:19 +00:00
Don't crash on malformed input when configuring a remote library.
This commit is contained in:
parent
c6f7faa3cb
commit
001afe6e9a
@ -54,7 +54,16 @@ using namespace cursespp;
|
||||
|
||||
#define R(x) (x->GetX() + x->GetWidth())
|
||||
|
||||
static const std::string kArrowSymbol = "> ";
|
||||
constexpr const char* kArrowSymbol = "> ";
|
||||
|
||||
static int getIntFromTextInput(TextInput& input, int defaultValue = -1) {
|
||||
try {
|
||||
return std::stoi(input.GetText());
|
||||
}
|
||||
catch (...) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int longestStringLength(const std::vector<std::string>&& keys) {
|
||||
int max = 0;
|
||||
@ -228,8 +237,8 @@ void RemoteLibrarySettingsLayout::SyncPreferencesAndLayout() {
|
||||
|
||||
void RemoteLibrarySettingsLayout::SavePreferences() {
|
||||
auto host = this->hostInput->GetText();
|
||||
auto wssPort = std::stoi(this->wssPortInput->GetText());
|
||||
auto httpPort = std::stoi(this->httpPortInput->GetText());
|
||||
auto wssPort = getIntFromTextInput(*this->wssPortInput, 7905);
|
||||
auto httpPort = getIntFromTextInput(*this->httpPortInput, 7906);
|
||||
auto password = this->pwInput->GetText();
|
||||
auto const wssTls = this->wssTlsCheckbox->IsChecked();
|
||||
auto const httpTls = this->httpTlsCheckbox->IsChecked();
|
||||
|
@ -565,7 +565,7 @@ int HttpServer::HandleAudioTrackRequest(
|
||||
#endif
|
||||
|
||||
if (response) {
|
||||
/* 'format' will be valid if we're transocding. otherwise, extract the extension
|
||||
/* 'format' will be valid if we're transcoding. otherwise, extract the extension
|
||||
from the filename. the client can use this as a hint when naming downloaded files */
|
||||
std::string extension = format.size() ? format : fileExtension(filename);
|
||||
MHD_add_response_header(response, "X-musikcube-File-Extension", extension.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user