Package: kde4libs / 4:4.14.2-5

allow_cancel_ssl.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
commit 38a89ca0195dedee30240647b86c7b6df6788723
Author: Dawit Alemayehu <adawit@kde.org>
Date:   Tue Nov 4 07:23:56 2014 -0500

    Allow user to cancel out of the certificate accept duration dialog box.
    
    BUG: 335375
    FIXED-IN: 4.14.3
    REVIEW: 120975

diff --git a/kio/kio/tcpslavebase.cpp b/kio/kio/tcpslavebase.cpp
index cdf28f0..fe83310 100644
--- a/kio/kio/tcpslavebase.cpp
+++ b/kio/kio/tcpslavebase.cpp
@@ -815,45 +815,51 @@ TCPSlaveBase::SslResult TCPSlaveBase::verifyServerCertificate()
     message = message.trimmed();
 
     int msgResult;
+    QDateTime ruleExpiry = QDateTime::currentDateTime();
     do {
         msgResult = messageBox(WarningYesNoCancel, message,
                                i18n("Server Authentication"),
                                i18n("&Details"), i18n("Co&ntinue"));
-        if (msgResult == KMessageBox::Yes) {
+        switch (msgResult) {
+        case KMessageBox::Yes:
             //Details was chosen- show the certificate and error details
             messageBox(SSLMessageBox /*the SSL info dialog*/, d->host);
-        } else if (msgResult == KMessageBox::Cancel) {
-            return ResultFailed;
-        } else if (msgResult != KMessageBox::No) {
+            break;
+        case KMessageBox::No: {
+                        //fall through on KMessageBox::No
+            const int result = messageBox(WarningYesNoCancel,
+                                    i18n("Would you like to accept this "
+                                        "certificate forever without "
+                                        "being prompted?"),
+                                    i18n("Server Authentication"),
+                                    i18n("&Forever"),
+                                    i18n("&Current Session only"));
+            if (result == KMessageBox::Yes) {
+                //accept forever ("for a very long time")
+                ruleExpiry = ruleExpiry.addYears(1000);
+            } else if (result == KMessageBox::No) {
+                //accept "for a short time", half an hour.
+                ruleExpiry = ruleExpiry.addSecs(30*60);
+            } else {
+                msgResult = KMessageBox::Yes;
+            }
+            break;
+        }
+        case KMessageBox::Cancel:
+            return ResultFailed;          
+        default:
             kWarning() << "Unexpected MessageBox response received:" << msgResult;
             return ResultFailed;
         }
-        //fall through on KMessageBox::No
     } while (msgResult == KMessageBox::Yes);
 
-    //Save the user's choice to ignore the SSL errors.
-
-    msgResult = messageBox(WarningYesNo,
-                            i18n("Would you like to accept this "
-                                 "certificate forever without "
-                                 "being prompted?"),
-                            i18n("Server Authentication"),
-                            i18n("&Forever"),
-                            i18n("&Current Session only"));
-    QDateTime ruleExpiry = QDateTime::currentDateTime();
-    if (msgResult == KMessageBox::Yes) {
-        //accept forever ("for a very long time")
-        ruleExpiry = ruleExpiry.addYears(1000);
-    } else {
-        //accept "for a short time", half an hour.
-        ruleExpiry = ruleExpiry.addSecs(30*60);
-    }
-
     //TODO special cases for wildcard domain name in the certificate!
     //rule = KSslCertificateRule(d->socket.peerCertificateChain().first(), whatever);
 
     rule.setExpiryDateTime(ruleExpiry);
     rule.setIgnoredErrors(d->sslErrors);
+
+    //Save the user's choice to ignore the SSL errors.
     cm->setRule(rule);
 
     return ResultOk | ResultOverridden;