Changeset - 5cb27b2e82d0
[Not reviewed]
0 1 0
dexterlb - 8 years ago 2017-12-26 21:38:25
dexterlb@qtrp.org
fix regex initialisation on C++98
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
libtransport/NetworkPluginServer.cpp
Show inline comments
 
@@ -1773,49 +1773,49 @@ void NetworkPluginServer::handleBuddyRemoved(Buddy *b) {
 
	User *user = b->getRosterManager()->getUser();
 

	
 
	pbnetwork::Buddy buddy;
 
	buddy.set_username(user->getJID().toBare());
 
	buddy.set_buddyname(b->getName());
 
	buddy.set_alias(b->getAlias());
 
	BOOST_FOREACH(const std::string &g, b->getGroups()) {
 
		buddy.add_group(g);
 
	}
 
	buddy.set_status(pbnetwork::STATUS_NONE);
 

	
 
	std::string message;
 
	buddy.SerializeToString(&message);
 

	
 
	WRAP(message, pbnetwork::WrapperMessage_Type_TYPE_BUDDY_REMOVED);
 

	
 
	Backend *c = (Backend *) user->getData();
 
	if (!c) {
 
		return;
 
	}
 
	send(c->connection, message);
 
}
 

	
 
void NetworkPluginServer::wrapIncomingImage(Swift::Message* msg, const pbnetwork::ConversationMessage& payload) {
 
    static boost::regex image_expr{"<img src=[\"']([^\"']+)[\"'].*>"};
 
    static boost::regex image_expr("<img src=[\"']([^\"']+)[\"'].*>");
 

	
 
    if (payload.xhtml().find("<img") != std::string::npos) {
 
        boost::smatch match;
 

	
 
        if (boost::regex_search(payload.xhtml(), match, image_expr)) {
 
            const std::string& image_url = match[1];
 

	
 
            SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::RawXMLPayload>
 
                oob_payload(new Swift::RawXMLPayload(
 
                    "<x xmlns='jabber:x:oob'><url>"
 
                    + image_url
 
                    + "</url>"
 
                    + "</x>"
 
                ));
 
                // todo: add the payload itself as a caption
 

	
 
            msg->addPayload(oob_payload);
 
            msg->setBody(image_url);
 
        } else {
 
            LOG4CXX_WARN(logger, "xhtml seems to contain an image, but doesn't match: " + payload.xhtml())
 
        }
 
    }
 
}
 

	
0 comments (0 inline, 0 general)