reinterpret_cast<const char*>(root->ns->href));
for (xmlNode* node = root->children; node; node = node->next) {
+ if (!node->name)
+ continue;
std::string sub_node_name(reinterpret_cast<const char*>(node->name));
std::unique_ptr<DictionaryValue> sub_value =
LoadXMLNode(node, constraints, current_dir);
std::unique_ptr<DictionaryValue> result(new DictionaryValue);
if (dv)
result->Set(reinterpret_cast<const char*>(root_node->name), dv.release());
+ xmlFreeDoc(doc);
return std::make_shared<parser::Manifest>(std::move(result));
}
: level_(level), tag_(tag) { }
void operator&(const StringStream<char>& str) const {
- dlog_print(LogLevelToPriority(level_), tag_.c_str(), str.str().c_str());
+ dlog_print(LogLevelToPriority(level_), tag_.c_str(),
+ Escape(str.str()).c_str());
static const char* app_installer_log = getenv("APP_INSTALLERS_LOG");
if (level_ == LogLevel::LOG_ERROR || app_installer_log != nullptr) {
}
}
private:
+ // Since LogCatcher passes input to dlog_print(), the input which contains
+ // format string(such as %d, %n) can cause unexpected result.
+ // This is simple function to escape '%'.
+ // NOTE: Is there any gorgeous way instead of this?
+ std::string Escape(const std::string& str) const {
+ std::string escaped = std::string(str);
+ size_t start_pos = 0;
+ std::string from = "%";
+ std::string to = "%%";
+ while ((start_pos = escaped.find(from, start_pos)) != std::string::npos) {
+ escaped.replace(start_pos, from.length(), to);
+ start_pos += to.length();
+ }
+ return escaped;
+ }
LogLevel level_;
std::string tag_;
};