5 changes: 3 additions & 2 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3132,10 +3132,11 @@ void Server::SendShowFormspecMessage(u16 peer_id, const std::string &formspec,
std::ostringstream os(std::ios_base::binary);
u8 buf[12];


// Write command
writeU16(buf, TOCLIENT_SHOW_FORMSPEC);
os.write((char*)buf, 2);
os<<serializeLongString(formspec);
os<<serializeLongString(FORMSPEC_VERSION_STRING + formspec);
os<<serializeString(formname);

// Make data buffer
Expand Down Expand Up @@ -3538,7 +3539,7 @@ void Server::SendPlayerInventoryFormspec(u16 peer_id)

std::ostringstream os(std::ios_base::binary);
writeU16(os, TOCLIENT_INVENTORY_FORMSPEC);
os<<serializeLongString(player->inventory_formspec);
os<<serializeLongString(FORMSPEC_VERSION_STRING + player->inventory_formspec);

// Make data buffer
std::string s = os.str();
Expand Down
14 changes: 14 additions & 0 deletions src/util/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <vector>
#include <sstream>

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

struct FlagDesc {
const char *name;
u32 flag;
Expand Down Expand Up @@ -316,6 +319,17 @@ inline std::string unescape_string(std::string &s)
return res;
}

inline bool is_number(const std::string& tocheck)
{
std::string::const_iterator iter = tocheck.begin();

while (iter != tocheck.end() && std::isdigit(*iter)) {
++iter;
}

return ((!tocheck.empty()) && (iter == tocheck.end()));
}

std::string translatePassword(std::string playername, std::wstring password);
std::string urlencode(std::string str);
std::string urldecode(std::string str);
Expand Down