Revert "wsd: preprocess javascript file for L10n"
This reverts commit 306b12b9bc
.
This commit is contained in:
parent
b2bd10445d
commit
2383a205c7
2 changed files with 1 additions and 38 deletions
|
@ -335,10 +335,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M
|
|||
const std::string fileType = endPoint.substr(extPoint + 1);
|
||||
std::string mimeType;
|
||||
if (fileType == "js")
|
||||
{
|
||||
preprocessJS(request, socket);
|
||||
return;
|
||||
}
|
||||
mimeType = "application/javascript";
|
||||
else if (fileType == "css")
|
||||
mimeType = "text/css";
|
||||
else if (fileType == "html")
|
||||
|
@ -1050,37 +1047,4 @@ void FileServerRequestHandler::parse(const std::locale& locale, std::istringstre
|
|||
ostr << varL10n.str();
|
||||
}
|
||||
}
|
||||
|
||||
void FileServerRequestHandler::preprocessJS(const HTTPRequest& request, const std::shared_ptr<StreamSocket>& socket)
|
||||
{
|
||||
std::string lang("en");
|
||||
Poco::Net::HTTPResponse response;
|
||||
const Poco::URI::QueryParameters params = Poco::URI(request.getURI()).getQueryParameters();
|
||||
auto pos = std::find_if(params.begin(), params.end(),
|
||||
[](const std::pair<std::string, std::string>& it) { return it.first == "lang"; });
|
||||
if (pos != params.end())
|
||||
lang = pos->second;
|
||||
|
||||
response.setContentType("application/javascript");
|
||||
response.set("User-Agent", HTTP_AGENT_STRING);
|
||||
response.set("Date", Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT));
|
||||
response.add("X-Content-Type-Options", "nosniff");
|
||||
|
||||
const std::string relPath = getRequestPathname(request);
|
||||
LOG_DBG("Preprocessing file: " << relPath);
|
||||
std::string preprocess = *getUncompressedFile(relPath);
|
||||
|
||||
std::ostringstream ostr;
|
||||
std::istringstream istr(preprocess);
|
||||
std::locale locale(LOOLWSD::Generator(lang + ".utf8"));
|
||||
|
||||
parse(locale, istr, ostr, [](const std::string&) { return false; });
|
||||
|
||||
std::ostringstream oss;
|
||||
response.write(oss);
|
||||
oss << ostr.str();
|
||||
socket->send(oss.str());
|
||||
|
||||
LOG_DBG("Sent file: " << relPath);
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -22,7 +22,6 @@ class FileServerRequestHandler
|
|||
|
||||
static void getToken(std::istringstream&, std::string&);
|
||||
static void parse(const std::locale&, std::istringstream&, std::ostringstream&, const std::function<bool(const std::string&)>&);
|
||||
static void preprocessJS(const Poco::Net::HTTPRequest& request, const std::shared_ptr<StreamSocket>& socket);
|
||||
static void preprocessFile(const Poco::Net::HTTPRequest& request, Poco::MemoryInputStream& message, const std::shared_ptr<StreamSocket>& socket);
|
||||
static void preprocessAdminFile(const Poco::Net::HTTPRequest& request, const std::shared_ptr<StreamSocket>& socket);
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue