HandlerPageView: Use revision from db, not query param, as template value.

Not a vulnerability, but more correct this way.
This commit is contained in:
Albert S. 2021-01-29 16:45:04 +01:00
父節點 0c66fdf70d
當前提交 dac07d23a9

查看文件

@ -162,19 +162,20 @@ Response HandlerPageView::handleRequest(PageDao &pageDao, std::string pagename,
this->cache->put(cachekeyparsedcontent, parsedcontent); this->cache->put(cachekeyparsedcontent, parsedcontent);
} }
} }
std::string revisionstr = std::to_string(revision->revision);
page.setVar("content", parsedcontent); page.setVar("content", parsedcontent);
page.setVar("index", indexcontent); page.setVar("index", indexcontent);
page.setVar("editedby", revision->author); page.setVar("editedby", revision->author);
page.setVar("editedon", utils::toISODate(revision->timestamp)); page.setVar("editedon", utils::toISODate(revision->timestamp));
page.setVar("historyurl", this->urlProvider->pageHistory(pagename)); page.setVar("historyurl", this->urlProvider->pageHistory(pagename));
page.setVar("revision", revisionparam); page.setVar("revision", revisionstr);
setPageVars(page, pagename); setPageVars(page, pagename);
std::string body = page.render(); std::string body = page.render();
if(revisionid == 0 && !this->userSession->loggedIn) if(revisionid == 0 && !this->userSession->loggedIn)
{ {
this->cache->put("page:foranon:" + pagename, body); this->cache->put("page:foranon:" + pagename, body);
} }
result.addHeader("ETAG", std::to_string(revision->revision) + "+" + std::to_string(this->userSession->loggedIn)); result.addHeader("ETAG", revisionstr + "+" + std::to_string(this->userSession->loggedIn));
result.setBody(body); result.setBody(body);
return result; return result;
} }