mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 06:35:08 -04:00
Fixed RetroShare links with "#" and some other "bad" characters in the file name.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3966 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
693bf4dd7c
commit
70c276fec6
2 changed files with 14 additions and 6 deletions
|
@ -104,7 +104,7 @@ void RetroShareLink::fromString(const QString& url)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now try QUrl */
|
/* Now try QUrl */
|
||||||
fromUrl(QUrl(url));
|
fromUrl(QUrl::fromEncoded(url.toAscii()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RetroShareLink::fromUrl(const QUrl& url)
|
void RetroShareLink::fromUrl(const QUrl& url)
|
||||||
|
@ -222,7 +222,7 @@ void RetroShareLink::check()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RetroShareLink::toString() const
|
QString RetroShareLink::toString(bool encoded /*= true*/) const
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case TYPE_UNKNOWN:
|
case TYPE_UNKNOWN:
|
||||||
|
@ -236,6 +236,10 @@ QString RetroShareLink::toString() const
|
||||||
url.addQueryItem(FILE_SIZE, QString::number(_size));
|
url.addQueryItem(FILE_SIZE, QString::number(_size));
|
||||||
url.addQueryItem(FILE_HASH, _hash);
|
url.addQueryItem(FILE_HASH, _hash);
|
||||||
|
|
||||||
|
if (encoded) {
|
||||||
|
return url.toEncoded();
|
||||||
|
}
|
||||||
|
|
||||||
return url.toString();
|
return url.toString();
|
||||||
}
|
}
|
||||||
case TYPE_PERSON:
|
case TYPE_PERSON:
|
||||||
|
@ -246,6 +250,10 @@ QString RetroShareLink::toString() const
|
||||||
url.addQueryItem(PERSON_NAME, _name);
|
url.addQueryItem(PERSON_NAME, _name);
|
||||||
url.addQueryItem(PERSON_HASH, _hash);
|
url.addQueryItem(PERSON_HASH, _hash);
|
||||||
|
|
||||||
|
if (encoded) {
|
||||||
|
return url.toEncoded();
|
||||||
|
}
|
||||||
|
|
||||||
return url.toString();
|
return url.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,17 +272,17 @@ QString RetroShareLink::niceName() const
|
||||||
|
|
||||||
QString RetroShareLink::toHtml() const
|
QString RetroShareLink::toHtml() const
|
||||||
{
|
{
|
||||||
return QString("<a href=\"") + toString() + "\">" + niceName() + "</a>" ;
|
return QString("<a href=\"") + toString(true) + "\">" + niceName() + "</a>" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RetroShareLink::toHtmlFull() const
|
QString RetroShareLink::toHtmlFull() const
|
||||||
{
|
{
|
||||||
return QString("<a href=\"") + toString() + "\">" + toString() + "</a>" ;
|
return QString("<a href=\"") + toString(true) + "\">" + toString(false) + "</a>" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RetroShareLink::toHtmlSize() const
|
QString RetroShareLink::toHtmlSize() const
|
||||||
{
|
{
|
||||||
return QString("<a href=\"") + toString() + "\">" + name() +"</a>" + " " + "<font color=\"blue\">" + "(" + misc::friendlyUnit(_size) + ")" +"</font>";
|
return QString("<a href=\"") + toString(true) + "\">" + name() +"</a>" + " " + "<font color=\"blue\">" + "(" + misc::friendlyUnit(_size) + ")" +"</font>";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RetroShareLink::checkName(const QString& name)
|
bool RetroShareLink::checkName(const QString& name)
|
||||||
|
|
|
@ -67,7 +67,7 @@ class RetroShareLink
|
||||||
|
|
||||||
/// returns the string retroshare://file?name=&size=&hash=
|
/// returns the string retroshare://file?name=&size=&hash=
|
||||||
/// retroshare://person?name=&hash=
|
/// retroshare://person?name=&hash=
|
||||||
QString toString() const ;
|
QString toString(bool encoded = true) const ;
|
||||||
/// returns the string <a href="retroshare://file?name=&size=&hash=">name</a>
|
/// returns the string <a href="retroshare://file?name=&size=&hash=">name</a>
|
||||||
/// <a href="retroshare://person?name=&hash=">name@hash</a>
|
/// <a href="retroshare://person?name=&hash=">name@hash</a>
|
||||||
QString toHtml() const ;
|
QString toHtml() const ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue