X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Furl_recipe.cpp;h=5d0c6ea37a4832e9f36248267a5b68c03f408d42;hb=02763589daff902e98af1cf6570bcf3e8cbcc6f1;hp=80769281658454a8c3f88f14d421370aadad8895;hpb=e5329397729e8959a821c6956f75012372fc0a77;p=metaproxy-moved-to-github.git diff --git a/src/url_recipe.cpp b/src/url_recipe.cpp index 8076928..5d0c6ea 100644 --- a/src/url_recipe.cpp +++ b/src/url_recipe.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2011 Index Data + Copyright (C) 2005-2012 Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -117,15 +117,19 @@ std::string mp_xml::url_recipe_handle(xmlDoc *doc, std::string recipe) break; } } - boost::regex::flag_type b_mode = boost::regex::perl; - if (mode.find_first_of('i') != std::string::npos) - b_mode |= boost::regex::icase; - boost::regex e(pattern, b_mode); - - boost::match_flag_type match_mode = boost::format_first_only; - if (mode.find_first_of('g') != std::string::npos) - match_mode = boost::format_all; - result += regex_replace(text, e, replacement, match_mode); + if (pattern.length() == 0) + result += text; + else + { + boost::regex::flag_type b_mode = boost::regex::perl; + if (mode.find_first_of('i') != std::string::npos) + b_mode |= boost::regex::icase; + boost::regex e(pattern, b_mode); + boost::match_flag_type match_mode = boost::format_first_only; + if (mode.find_first_of('g') != std::string::npos) + match_mode = boost::format_all; + result += regex_replace(text, e, replacement, match_mode); + } } } return result;