mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
auto-cleaning of strings for types that cannot contain chars < 0x20 by design
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8547 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f7e147c35d
commit
e1dcdd78b6
@ -579,6 +579,33 @@ bool GetTlvString(void *data, uint32_t size, uint32_t *offset,
|
||||
break ;
|
||||
}
|
||||
|
||||
// Also check that the string does not contain invalid characters.
|
||||
// Every character less than 0x20 will be turned into a space (0x20).
|
||||
// This is compatible with utf8, as all utf8 chars are > 0x7f.
|
||||
// We do this for strings that should not contain some
|
||||
// special characters by design.
|
||||
|
||||
if( type == 0 // this is used for mGroupName and mMsgName
|
||||
|| type == TLV_TYPE_STR_PEERID
|
||||
|| type == TLV_TYPE_STR_NAME
|
||||
|| type == TLV_TYPE_STR_PATH
|
||||
|| type == TLV_TYPE_STR_TITLE
|
||||
|| type == TLV_TYPE_STR_SUBJECT
|
||||
|| type == TLV_TYPE_STR_LOCATION
|
||||
|| type == TLV_TYPE_STR_VERSION )
|
||||
{
|
||||
bool modified = false ;
|
||||
for(uint32_t i=0;i<in.length();++i)
|
||||
if(in[i] < 0x20 && in[i] > 0)
|
||||
{
|
||||
modified = true ;
|
||||
in[i] = 0x20 ;
|
||||
}
|
||||
|
||||
if(modified)
|
||||
std::cerr << "(WW) De-serialised string of type " << type << " contains forbidden characters. They have been replaced by spaces. New string: \"" << in << "\"" << std::endl;
|
||||
}
|
||||
|
||||
*offset += tlvsize; /* step along */
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user