diff options
-rw-r--r-- | backends/networking/sdl_net/handlers/filespagehandler.cpp | 26 | ||||
-rw-r--r-- | backends/networking/sdl_net/localwebserver.cpp | 1 | ||||
-rw-r--r-- | backends/networking/wwwroot.zip | bin | 233020 -> 233169 bytes | |||
-rw-r--r-- | backends/networking/wwwroot/.files.html | 1 | ||||
-rw-r--r-- | backends/networking/wwwroot/style.css | 7 |
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 += "<"; + else if (s[i] == '>') result += ">"; + else if (s[i] == '&') result += "&"; + 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 Binary files differindex 6f695e0639..48e8cb6bf8 100644 --- a/backends/networking/wwwroot.zip +++ b/backends/networking/wwwroot.zip 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; +} |