Skip to content

Commit

Permalink
Upd: Do not ignore invalid requests, respond with error
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Oct 11, 2024
1 parent 24e8883 commit 29f99db
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
28 changes: 14 additions & 14 deletions docs/_includes/translating_status.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
- bg-BG: 1087 missing phrases
- es-AR: 4 missing phrases
- es-ES: 954 missing phrases
- es-VE: 942 missing phrases
- fi-FI: 939 missing phrases
- fr-FR: 4 missing phrases
- it-IT: 4 missing phrases
- ja-JP: 4 missing phrases
- ko-KR: 4 missing phrases
- nl-NL: 4 missing phrases
- pl-PL: 87 missing phrases
- ru-RU: 35 missing phrases
- zh-Hans: 4 missing phrases
- zh-Hant: 121 missing phrases
- bg-BG: 1088 missing phrases
- es-AR: 5 missing phrases
- es-ES: 955 missing phrases
- es-VE: 943 missing phrases
- fi-FI: 940 missing phrases
- fr-FR: 5 missing phrases
- it-IT: 5 missing phrases
- ja-JP: 5 missing phrases
- ko-KR: 5 missing phrases
- nl-NL: 5 missing phrases
- pl-PL: 88 missing phrases
- ru-RU: 36 missing phrases
- zh-Hans: 5 missing phrases
- zh-Hant: 122 missing phrases
3 changes: 2 additions & 1 deletion src/i18n/json/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -1233,5 +1233,6 @@
"Split a multiline string in lines.": "Teilt einen mehrzeiligen String in einzelne Zeilen.",
"Trims a string.": "Trimt einen String.",
"Sleeps number of milliseconds.": "Wartet die Spanne von Millisekunden.",
"Read an ascii file.": "Liest eine Textdatei ein."
"Read an ascii file.": "Liest eine Textdatei ein.",
"Invalid API uri, partition not found": "Ungültige API URI, Partition nicht gefunden."
}
18 changes: 9 additions & 9 deletions src/i18n/json/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"default": {"desc":"Browser default", "missingPhrases": 0},
"de-DE": {"desc":"Deutsch (de-DE)", "missingPhrases": 0},
"en-US": {"desc":"English (en-US)", "missingPhrases": 0},
"es-AR": {"desc":"Español (es-AR)", "missingPhrases": 4},
"fr-FR": {"desc":"Français (fr-FR)", "missingPhrases": 4},
"it-IT": {"desc":"Italiano (it-IT)", "missingPhrases": 4},
"ja-JP": {"desc":"日本語 (ja-JP)", "missingPhrases": 4},
"ko-KR": {"desc":"한국어 (ko-KR)", "missingPhrases": 4},
"nl-NL": {"desc":"Nederlands (nl-NL)", "missingPhrases": 4},
"pl-PL": {"desc":"Polish (pl-PL)", "missingPhrases": 87},
"ru-RU": {"desc":"Russian (ru-RU)", "missingPhrases": 35},
"zh-Hans": {"desc":"简体中文 (zh-Hans)", "missingPhrases": 4}
"es-AR": {"desc":"Español (es-AR)", "missingPhrases": 5},
"fr-FR": {"desc":"Français (fr-FR)", "missingPhrases": 5},
"it-IT": {"desc":"Italiano (it-IT)", "missingPhrases": 5},
"ja-JP": {"desc":"日本語 (ja-JP)", "missingPhrases": 5},
"ko-KR": {"desc":"한국어 (ko-KR)", "missingPhrases": 5},
"nl-NL": {"desc":"Nederlands (nl-NL)", "missingPhrases": 5},
"pl-PL": {"desc":"Polish (pl-PL)", "missingPhrases": 88},
"ru-RU": {"desc":"Russian (ru-RU)", "missingPhrases": 36},
"zh-Hans": {"desc":"简体中文 (zh-Hans)", "missingPhrases": 5}
}
1 change: 1 addition & 0 deletions src/i18n/json/phrases.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@
{"term":"Insert mode"},
{"term":"Interval"},
{"term":"Invalid API request"},
{"term":"Invalid API uri, partition not found"},
{"term":"Invalid MPD search expression"},
{"term":"Invalid URI"},
{"term":"Invalid backend uri"},
Expand Down
10 changes: 10 additions & 0 deletions src/web_server/web_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,10 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
//check partition
if (get_partition_from_uri(nc, hm, frontend_nc_data) == false) {
MYMPD_LOG_ERROR(NULL, "API request without partition");
sds response = jsonrpc_respond_message(sdsempty(), GENERAL_API_UNKNOWN, 0,
JSONRPC_FACILITY_GENERAL, JSONRPC_SEVERITY_ERROR, "Invalid API uri, partition not found");
webserver_send_data(nc, response, sdslen(response), EXTRA_HEADERS_JSON_CONTENT);
FREE_SDS(response);
break;
}
//body
Expand Down Expand Up @@ -777,6 +781,7 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
//check partition
if (get_partition_from_uri(nc, hm, frontend_nc_data) == false) {
MYMPD_LOG_ERROR(NULL, "Websocket request without partition");
webserver_send_error(nc, 404, "Invalid websocket uri, partition not found");
break;
}
mg_ws_upgrade(nc, hm, NULL);
Expand All @@ -789,6 +794,7 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
//check partition
if (get_partition_from_uri(nc, hm, frontend_nc_data) == false) {
MYMPD_LOG_ERROR(NULL, "Stream request without partition");
webserver_send_error(nc, 404, "Invalid stream uri, partition not found");
break;
}
struct t_list_node *node = list_get_node(&mg_user_data->stream_uris, frontend_nc_data->partition);
Expand Down Expand Up @@ -819,6 +825,10 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
//check partition
if (get_partition_from_uri(nc, hm, frontend_nc_data) == false) {
MYMPD_LOG_ERROR(NULL, "script-api request without partition");
sds response = jsonrpc_respond_message(sdsempty(), GENERAL_API_UNKNOWN, 0,
JSONRPC_FACILITY_GENERAL, JSONRPC_SEVERITY_ERROR, "Invalid API uri, partition not found");
webserver_send_data(nc, response, sdslen(response), EXTRA_HEADERS_JSON_CONTENT);
FREE_SDS(response);
break;
}
sds body = sdsnewlen(hm->body.buf, hm->body.len);
Expand Down

0 comments on commit 29f99db

Please sign in to comment.