From fefe22b4aa5194af499763d3cc4d4dc19116fa92 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 18 Dec 2011 18:37:54 +0000 Subject: (svn r23590) -Codechange: make the string validation settings better expandable --- src/network/core/packet.cpp | 6 +++--- src/network/core/packet.h | 3 ++- src/network/network_content.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/network') diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index d30ef9e5f..4d9345e82 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -283,9 +283,9 @@ uint64 Packet::Recv_uint64() * Reads a string till it finds a '\0' in the stream. * @param buffer The buffer to put the data into. * @param size The size of the buffer. - * @param allow_newlines Whether the string validation should remove newlines. + * @param settings The string validation settings. */ -void Packet::Recv_string(char *buffer, size_t size, bool allow_newlines) +void Packet::Recv_string(char *buffer, size_t size, StringValidationSettings settings) { PacketSize pos; char *bufp = buffer; @@ -306,7 +306,7 @@ void Packet::Recv_string(char *buffer, size_t size, bool allow_newlines) } this->pos = pos; - str_validate(bufp, last, allow_newlines); + str_validate(bufp, last, settings); } #endif /* ENABLE_NETWORK */ diff --git a/src/network/core/packet.h b/src/network/core/packet.h index ef9da056a..7f344d017 100644 --- a/src/network/core/packet.h +++ b/src/network/core/packet.h @@ -16,6 +16,7 @@ #include "config.h" #include "core.h" +#include "../../string_type.h" #ifdef ENABLE_NETWORK @@ -83,7 +84,7 @@ public: uint16 Recv_uint16(); uint32 Recv_uint32(); uint64 Recv_uint64(); - void Recv_string(char *buffer, size_t size, bool allow_newlines = false); + void Recv_string(char *buffer, size_t size, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK); }; #endif /* ENABLE_NETWORK */ diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 179603768..6499e5274 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -56,7 +56,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p) p->Recv_string(ci->name, lengthof(ci->name)); p->Recv_string(ci->version, lengthof(ci->name)); p->Recv_string(ci->url, lengthof(ci->url)); - p->Recv_string(ci->description, lengthof(ci->description), true); + p->Recv_string(ci->description, lengthof(ci->description), SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE); ci->unique_id = p->Recv_uint32(); for (uint j = 0; j < sizeof(ci->md5sum); j++) { -- cgit v1.2.3-70-g09d2