Project

General

Profile

Bug #3668 » wt-3.3.4-rc1-gnu-regex-refencoder.patch

Laurence Withers, 11/18/2014 06:41 PM

View differences:

src/web/RefEncoder.C
#include "WebSession.h"
#include "WebUtils.h"
#include <boost/regex.hpp>
#include <boost/algorithm/string/trim.hpp>
#include "3rdparty/rapidxml/rapidxml.hpp"
#include "3rdparty/rapidxml/rapidxml_print.hpp"
......
static std::string replaceUrlInStyle(std::string& style, WApplication *app)
{
boost::regex re("url\\((.*//.*)\\)",
boost::regex::perl | boost::regex::icase);
boost::sregex_iterator i(style.begin(), style.end(), re);
boost::sregex_iterator end;
WStringStream result;
std::size_t pos = 0;
std::size_t pos = 0, urlPos, schemePos, closePos;
while ((urlPos = style.find("url(", pos)) != std::string::npos) {
urlPos += 4;
result << style.substr(pos, urlPos - pos);
pos = urlPos;
for (; i != end; ++i) {
result << style.substr(pos, i->position(1) - pos);
schemePos = style.find("//", pos);
if (schemePos == std::string::npos)
continue;
closePos = style.find(')', pos);
if (closePos == std::string::npos || closePos < schemePos)
continue;
std::string url = style.substr(i->position(1), i->length(1));
std::string url = style.substr(pos, closePos - pos);
boost::algorithm::trim(url);
if (url.length() > 2)
if (url[0] == '\'' || url[1] == '"')
......
result << WWebWidget::jsStringLiteral(app->encodeUntrustedUrl(url), '\'');
pos = i->position(1) + i->length(1);
pos = closePos;
}
result << style.substr(pos);
(3-3/4)