Skip to content

Commit dcb39e4

Browse files
committed
Support local file paths with diacritic characters in them
1 parent 66b1763 commit dcb39e4

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

Diff for: shared/browser-scheme.cpp

+12-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <include/cef_parser.h>
44

55
#include "browser-scheme.hpp"
6+
#include "obs.h"
67

78

89
BrowserSchemeHandlerFactory::BrowserSchemeHandlerFactory()
@@ -33,18 +34,20 @@ bool BrowserSchemeHandler::ProcessRequest(CefRefPtr<CefRequest> request,
3334
CefURLParts parts;
3435
CefParseURL(request->GetURL(), parts);
3536

36-
std::string path = CefString(&parts.path);
37-
38-
// Set fileName for use in GetResponseHeaders
39-
fileName = path;
37+
std::wstring path = CefString(&parts.path);
4038

4139
path = CefURIDecode(path, true, cef_uri_unescape_rule_t::UU_SPACES);
42-
path = CefURIDecode(path, true, cef_uri_unescape_rule_t::UU_NORMAL);
40+
path = CefURIDecode(path, true, cef_uri_unescape_rule_t::UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS);
4341
#ifdef WIN32
42+
//blog(LOG_INFO, "%s", path.erase(0,1));
4443
inputStream.open(path.erase(0,1), std::ifstream::binary);
4544
#else
4645
inputStream.open(path, std::ifstream::binary);
4746
#endif
47+
48+
// Set fileName for use in GetResponseHeaders
49+
fileName = path;
50+
4851
if (!inputStream.is_open()) {
4952
callback->Cancel();
5053
return false;
@@ -66,11 +69,11 @@ void BrowserSchemeHandler::GetResponseHeaders(CefRefPtr<CefResponse> response,
6669
return;
6770
}
6871

69-
std::string fileExtension = fileName.substr(
70-
fileName.find_last_of(".") + 1);
72+
std::wstring fileExtension = fileName.substr(
73+
fileName.find_last_of(L".") + 1);
7174

72-
if (fileExtension == "woff2") {
73-
fileExtension = "woff";
75+
if (fileExtension.compare(L"woff2") == 0) {
76+
fileExtension = L"woff";
7477
}
7578

7679
std::transform(fileExtension.begin(), fileExtension.end(),

Diff for: shared/browser-scheme.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BrowserSchemeHandler : public CefResourceHandler {
5151

5252

5353
private:
54-
std::string fileName;
54+
std::wstring fileName;
5555
std::ifstream inputStream;
5656
bool isComplete;
5757
int64 length;

0 commit comments

Comments
 (0)