mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
f4cd4dbdb0
commit
2f2d01dc41
@ -44,7 +44,6 @@ extern RsIdentity *rsIdentity;
|
||||
// GroupFlags: Only one so far:
|
||||
#define RSGXSID_GROUPFLAG_REALID 0x0001
|
||||
|
||||
|
||||
// THESE ARE FLAGS FOR INTERFACE.
|
||||
#define RSID_TYPE_MASK 0xff00
|
||||
#define RSID_RELATION_MASK 0x00ff
|
||||
@ -60,6 +59,8 @@ extern RsIdentity *rsIdentity;
|
||||
|
||||
#define RSRECOGN_MAX_TAGINFO 5
|
||||
|
||||
#define RSID_MAXIMUM_NICKNAME_SIZE 30
|
||||
|
||||
std::string rsIdTypeToString(uint32_t idtype);
|
||||
|
||||
class GxsReputation
|
||||
|
@ -390,7 +390,7 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||
if (!item)
|
||||
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->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
|
||||
|
@ -257,7 +257,7 @@ void IdEditDialog::loadExistingId(uint32_t token)
|
||||
// force - incase it wasn't triggered.
|
||||
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()));
|
||||
|
||||
if (realid)
|
||||
@ -297,7 +297,7 @@ void IdEditDialog::checkNewTag()
|
||||
{
|
||||
std::string tag = ui->plainTextEdit_Tag->toPlainText().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;
|
||||
bool ok = tagDetails(id, name, tag, desc);
|
||||
@ -488,7 +488,12 @@ void IdEditDialog::createId()
|
||||
std::cerr << std::endl;
|
||||
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;
|
||||
params.nickname = groupname;
|
||||
params.isPgpLinked = (ui->radioButton_GpgId->isChecked());
|
||||
@ -538,6 +543,12 @@ void IdEditDialog::updateId()
|
||||
std::cerr << std::endl;
|
||||
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;
|
||||
|
||||
|
@ -828,7 +828,7 @@ bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QLi
|
||||
|
||||
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;
|
||||
for (it = details.mRecognTags.begin(); it != details.mRecognTags.end(); ++it)
|
||||
@ -843,7 +843,7 @@ QString GxsIdDetails::getComment(const RsIdentityDetails &details)
|
||||
{
|
||||
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 name"),
|
||||
nickname,
|
||||
|
Loading…
Reference in New Issue
Block a user