aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpaster/pastebindotcomprotocol.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-05-08 16:07:07 +0200
committerFriedemann Kleint <Friedemann.Kleint@digia.com>2013-05-10 09:07:11 +0200
commitcd8cd4fdb11e54d241748ed72f480aaf641d1161 (patch)
tree62f93c9955568f497adc3123bb8839ef433ab2b6 /src/plugins/cpaster/pastebindotcomprotocol.cpp
parent4dd4bff88601f8092562dfe2082ead360cad90e0 (diff)
Fix expiry specification for Pastebin.com.
The site accepts only a fixed set of specifications. Task-number: QTCREATORBUG-9270 Change-Id: I777b8bdff972a64d6e268adeb29f266c754cbad7 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Diffstat (limited to 'src/plugins/cpaster/pastebindotcomprotocol.cpp')
-rw-r--r--src/plugins/cpaster/pastebindotcomprotocol.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/plugins/cpaster/pastebindotcomprotocol.cpp b/src/plugins/cpaster/pastebindotcomprotocol.cpp
index 364ad516e2..619c2238ca 100644
--- a/src/plugins/cpaster/pastebindotcomprotocol.cpp
+++ b/src/plugins/cpaster/pastebindotcomprotocol.cpp
@@ -97,6 +97,19 @@ static inline QByteArray format(Protocol::ContentType ct)
return format;
}
+// According to documentation, Pastebin.com accepts only fixed expiry specifications:
+// N = Never, 10M = 10 Minutes, 1H = 1 Hour, 1D = 1 Day, 1W = 1 Week, 2W = 2 Weeks, 1M = 1 Month,
+// however, 1W and 2W do not work.
+
+static inline QByteArray expirySpecification(int expiryDays)
+{
+ if (expiryDays <= 1)
+ return QByteArray("1D");
+ if (expiryDays <= 31)
+ return QByteArray("1M");
+ return QByteArray("N");
+}
+
void PasteBinDotComProtocol::paste(const QString &text,
ContentType ct, int expiryDays,
const QString &username,
@@ -111,8 +124,8 @@ void PasteBinDotComProtocol::paste(const QString &text,
QByteArray pasteData = API_KEY;
pasteData += "api_option=paste&";
pasteData += "api_paste_expire_date=";
- pasteData += QByteArray::number(expiryDays);
- pasteData += "D&";
+ pasteData += expirySpecification(expiryDays);
+ pasteData += '&';
pasteData += format(ct);
pasteData += "api_paste_name=";
pasteData += QUrl::toPercentEncoding(username);