set max GxsId nickname size to some arbitrary value to avoid crazy long nicknames crafted to break the GUI. This should also be checked when de-serialising groups at a wider scale for group names in general

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8125 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-04-09 19:53:01 +00:00
parent f4cd4dbdb0
commit 2f2d01dc41
4 changed files with 19 additions and 7 deletions

View File

@ -44,7 +44,6 @@ extern RsIdentity *rsIdentity;
// GroupFlags: Only one so far: // GroupFlags: Only one so far:
#define RSGXSID_GROUPFLAG_REALID 0x0001 #define RSGXSID_GROUPFLAG_REALID 0x0001
// THESE ARE FLAGS FOR INTERFACE. // THESE ARE FLAGS FOR INTERFACE.
#define RSID_TYPE_MASK 0xff00 #define RSID_TYPE_MASK 0xff00
#define RSID_RELATION_MASK 0x00ff #define RSID_RELATION_MASK 0x00ff
@ -60,6 +59,8 @@ extern RsIdentity *rsIdentity;
#define RSRECOGN_MAX_TAGINFO 5 #define RSRECOGN_MAX_TAGINFO 5
#define RSID_MAXIMUM_NICKNAME_SIZE 30
std::string rsIdTypeToString(uint32_t idtype); std::string rsIdTypeToString(uint32_t idtype);
class GxsReputation class GxsReputation

View File

@ -390,7 +390,7 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
if (!item) if (!item)
item = new QTreeWidgetItem(); item = new QTreeWidgetItem();
item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str())); item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE));
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString())); item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ; item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;

View File

@ -257,7 +257,7 @@ void IdEditDialog::loadExistingId(uint32_t token)
// force - incase it wasn't triggered. // force - incase it wasn't triggered.
idTypeToggled(true); idTypeToggled(true);
ui->lineEdit_Nickname->setText(QString::fromUtf8(mEditGroup.mMeta.mGroupName.c_str())); ui->lineEdit_Nickname->setText(QString::fromUtf8(mEditGroup.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE));
ui->lineEdit_KeyId->setText(QString::fromStdString(mEditGroup.mMeta.mGroupId.toStdString())); ui->lineEdit_KeyId->setText(QString::fromStdString(mEditGroup.mMeta.mGroupId.toStdString()));
if (realid) if (realid)
@ -297,7 +297,7 @@ void IdEditDialog::checkNewTag()
{ {
std::string tag = ui->plainTextEdit_Tag->toPlainText().toStdString(); std::string tag = ui->plainTextEdit_Tag->toPlainText().toStdString();
RsGxsId id ( ui->lineEdit_KeyId->text().toStdString()); RsGxsId id ( ui->lineEdit_KeyId->text().toStdString());
std::string name = ui->lineEdit_Nickname->text().toUtf8().data(); std::string name = ui->lineEdit_Nickname->text().left(RSID_MAXIMUM_NICKNAME_SIZE).toUtf8().data();
QString desc; QString desc;
bool ok = tagDetails(id, name, tag, desc); bool ok = tagDetails(id, name, tag, desc);
@ -488,7 +488,12 @@ void IdEditDialog::createId()
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
if (groupname.size() > RSID_MAXIMUM_NICKNAME_SIZE)
{
std::cerr << "IdEditDialog::createId() Nickname too long (max " << RSID_MAXIMUM_NICKNAME_SIZE<< " chars)";
std::cerr << std::endl;
return;
}
RsIdentityParameters params; RsIdentityParameters params;
params.nickname = groupname; params.nickname = groupname;
params.isPgpLinked = (ui->radioButton_GpgId->isChecked()); params.isPgpLinked = (ui->radioButton_GpgId->isChecked());
@ -538,6 +543,12 @@ void IdEditDialog::updateId()
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
if (groupname.size() > RSID_MAXIMUM_NICKNAME_SIZE)
{
std::cerr << "IdEditDialog::createId() Nickname too long (max " << RSID_MAXIMUM_NICKNAME_SIZE << " chars)";
std::cerr << std::endl;
return;
}
mEditGroup.mMeta.mGroupName = groupname; mEditGroup.mMeta.mGroupName = groupname;

View File

@ -828,7 +828,7 @@ bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QLi
QString GxsIdDetails::getName(const RsIdentityDetails &details) QString GxsIdDetails::getName(const RsIdentityDetails &details)
{ {
QString name = QString::fromUtf8(details.mNickname.c_str()); QString name = QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE);
std::list<RsRecognTag>::const_iterator it; std::list<RsRecognTag>::const_iterator it;
for (it = details.mRecognTags.begin(); it != details.mRecognTags.end(); ++it) for (it = details.mRecognTags.begin(); it != details.mRecognTags.end(); ++it)
@ -843,7 +843,7 @@ QString GxsIdDetails::getComment(const RsIdentityDetails &details)
{ {
QString comment; QString comment;
QString nickname = details.mNickname.empty()?tr("[Unknown]"):QString::fromUtf8(details.mNickname.c_str()) ; QString nickname = details.mNickname.empty()?tr("[Unknown]"):QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE) ;
comment = QString("%1:%2<br/>%3:%4").arg(QApplication::translate("GxsIdDetails", "Identity&nbsp;name"), comment = QString("%1:%2<br/>%3:%4").arg(QApplication::translate("GxsIdDetails", "Identity&nbsp;name"),
nickname, nickname,