aboutsummaryrefslogtreecommitdiff
path: root/backends/networking
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-16 11:34:35 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit6c0f491c4f8e809d5d2e5fd070461db1c9777958 (patch)
treebbb96fd66faf720d8f2e6d531bd3eb0efe34bba5 /backends/networking
parentded8cdf0a092894781bb4d93f2d1e9d061878ea1 (diff)
downloadscummvm-rg350-6c0f491c4f8e809d5d2e5fd070461db1c9777958.tar.gz
scummvm-rg350-6c0f491c4f8e809d5d2e5fd070461db1c9777958.tar.bz2
scummvm-rg350-6c0f491c4f8e809d5d2e5fd070461db1c9777958.zip
CLOUD: Add "Index of" label in server's "/files"
Diffstat (limited to 'backends/networking')
-rw-r--r--backends/networking/sdl_net/handlers/filespagehandler.cpp26
-rw-r--r--backends/networking/sdl_net/localwebserver.cpp1
-rw-r--r--backends/networking/wwwroot.zipbin233020 -> 233169 bytes
-rw-r--r--backends/networking/wwwroot/.files.html1
-rw-r--r--backends/networking/wwwroot/style.css7
5 files changed, 31 insertions, 4 deletions
diff --git a/backends/networking/sdl_net/handlers/filespagehandler.cpp b/backends/networking/sdl_net/handlers/filespagehandler.cpp
index 1b8ab463bc..5ead4f31d9 100644
--- a/backends/networking/sdl_net/handlers/filespagehandler.cpp
+++ b/backends/networking/sdl_net/handlers/filespagehandler.cpp
@@ -43,6 +43,26 @@ Common::String encodeDoubleQuotes(Common::String s) {
} else result += s[i];
return result;
}
+
+Common::String encodeHtmlEntities(Common::String s) {
+ Common::String result = "";
+ for (uint32 i = 0; i < s.size(); ++i)
+ if (s[i] == '<') result += "&lt;";
+ else if (s[i] == '>') result += "&gt;";
+ else if (s[i] == '&') result += "&amp;";
+ else if (s[i] > 0x7F) result += Common::String::format("&#%d;", (int)s[i]);
+ else result += s[i];
+ return result;
+}
+
+Common::String getDisplayPath(Common::String s) {
+ Common::String result = "";
+ for (uint32 i = 0; i < s.size(); ++i)
+ if (s[i] == '\\') result += '/';
+ else result += s[i];
+ if (result == "") return "/";
+ return result;
+}
}
void FilesPageHandler::handle(Client &client) {
@@ -65,6 +85,7 @@ void FilesPageHandler::handle(Client &client) {
"<input type=\"submit\" value=\"{upload_file_button}\"/>" \
"</form>"
"<hr/>" \
+ "<h1>{index_of_directory}</h1>" \
"<table>{content}</table>" \
"</body>" \
"</html>";
@@ -93,7 +114,8 @@ void FilesPageHandler::handle(Client &client) {
replace(response, "{create_directory_desc}", _("Type new directory name:"));
replace(response, "{upload_file_desc}", _("Select a file to upload:"));
replace(response, "{or_upload_directory_desc}", _("Or select a directory (works in Chrome only):"));
- replace(response, "{content}", content);
+ replace(response, "{index_of_directory}", Common::String::format(_("Index of %s"), encodeHtmlEntities(getDisplayPath(client.queryParameter("path"))).c_str()));
+ replace(response, "{content}", content);
LocalWebserver::setClientGetHandler(client, response);
}
@@ -167,7 +189,7 @@ void FilesPageHandler::addItem(Common::String &content, const Common::String &it
}
replace(item, "{icon}", icon);
replace(item, "{link}", (isDirectory ? "files?path=" : "download?path=") + LocalWebserver::urlEncodeQueryParameterValue(path));
- replace(item, "{name}", name);
+ replace(item, "{name}", encodeHtmlEntities(name));
replace(item, "{size}", size);
content += item;
}
diff --git a/backends/networking/sdl_net/localwebserver.cpp b/backends/networking/sdl_net/localwebserver.cpp
index 9d53543df2..1999fe9f7f 100644
--- a/backends/networking/sdl_net/localwebserver.cpp
+++ b/backends/networking/sdl_net/localwebserver.cpp
@@ -426,5 +426,4 @@ Common::String LocalWebserver::urlEncodeQueryParameterValue(Common::String value
return result;
}
-
} // End of namespace Networking
diff --git a/backends/networking/wwwroot.zip b/backends/networking/wwwroot.zip
index 6f695e0639..48e8cb6bf8 100644
--- a/backends/networking/wwwroot.zip
+++ b/backends/networking/wwwroot.zip
Binary files differ
diff --git a/backends/networking/wwwroot/.files.html b/backends/networking/wwwroot/.files.html
index 2c0bceb333..f05c0113f8 100644
--- a/backends/networking/wwwroot/.files.html
+++ b/backends/networking/wwwroot/.files.html
@@ -39,6 +39,7 @@
</div>
<div class="content">
<table class="files_list">
+ <td></td><td><b class="directory_name">{index_of_directory}</b></td><td></td>
{content}
</table>
</div>
diff --git a/backends/networking/wwwroot/style.css b/backends/networking/wwwroot/style.css
index d8fcfd3654..cc3a859137 100644
--- a/backends/networking/wwwroot/style.css
+++ b/backends/networking/wwwroot/style.css
@@ -87,4 +87,9 @@ html {
cursor: pointer;
}
-td img { vertical-align: middle; height: 20px; } \ No newline at end of file
+td img { vertical-align: middle; height: 20px; }
+
+.directory_name {
+ display: block;
+ padding-bottom: 6px;
+}