summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c98
1 files changed, 66 insertions, 32 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 0a8197b5..b6bfe948 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1548,53 +1548,87 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1548 updateWindowTitle_DocumentWidget_(d); 1548 updateWindowTitle_DocumentWidget_(d);
1549 return iFalse; 1549 return iFalse;
1550 } 1550 }
1551 else if (equal_Command(cmd, "server.showcert") && d == document_App()) { 1551 else if (equal_Command(cmd, "document.info") && d == document_App()) {
1552 const char *unchecked = red_ColorEscape "\u2610"; 1552 const char *unchecked = red_ColorEscape "\u2610";
1553 const char *checked = green_ColorEscape "\u2611"; 1553 const char *checked = green_ColorEscape "\u2611";
1554 const char *actionLabels[] = { "Dismiss", uiTextCaution_ColorEscape "Trust" }; 1554 const char *actionLabels[] = { uiTextCaution_ColorEscape "Trust", "Copy Fingerprint", "Dismiss" };
1555 const char *actionCmds[] = { "message.ok", "server.trustcert" }; 1555 const char *actionCmds[] = { "server.trustcert", "server.copycert", "message.ok" };
1556 const iBool canTrust = 1556 const iBool canTrust =
1557 (d->certFlags == (available_GmCertFlag | haveFingerprint_GmCertFlag | 1557 (d->certFlags == (available_GmCertFlag | haveFingerprint_GmCertFlag |
1558 timeVerified_GmCertFlag | domainVerified_GmCertFlag)); 1558 timeVerified_GmCertFlag | domainVerified_GmCertFlag));
1559 iWidget *dlg = makeQuestion_Widget( 1559 const iRecentUrl *recent = findUrl_History(d->mod.history, d->mod.url);
1560 uiHeading_ColorEscape "CERTIFICATE STATUS", 1560 const iString *meta = &d->sourceMime;
1561 format_CStr("%s%s Domain name %s%s\n" 1561 if (recent && recent->cachedResponse) {
1562 "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n" 1562 meta = &recent->cachedResponse->meta;
1563 "%s%s %s", 1563 }
1564 d->certFlags & domainVerified_GmCertFlag ? checked : unchecked, 1564 iString *msg = collectNew_String();
1565 uiText_ColorEscape, 1565 format_String(msg,
1566 d->certFlags & domainVerified_GmCertFlag ? "matches" : "mismatch", 1566 "%sCertificate Status:\n%s%s Domain name %s%s\n"
1567 ~d->certFlags & domainVerified_GmCertFlag 1567 "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n"
1568 ? format_CStr(" (%s)", cstr_String(d->certSubject)) 1568 "%s%s %s",
1569 : "", 1569 uiHeading_ColorEscape,
1570 d->certFlags & timeVerified_GmCertFlag ? checked : unchecked, 1570 d->certFlags & domainVerified_GmCertFlag ? checked : unchecked,
1571 uiText_ColorEscape, 1571 uiText_ColorEscape,
1572 d->certFlags & timeVerified_GmCertFlag ? "Not expired" : "Expired", 1572 d->certFlags & domainVerified_GmCertFlag ? "matches" : "mismatch",
1573 d->certExpiry.year, 1573 ~d->certFlags & domainVerified_GmCertFlag
1574 d->certExpiry.month, 1574 ? format_CStr(" (%s)", cstr_String(d->certSubject))
1575 d->certExpiry.day, 1575 : "",
1576 d->certExpiry.hour, 1576 d->certFlags & timeVerified_GmCertFlag ? checked : unchecked,
1577 d->certExpiry.minute, 1577 uiText_ColorEscape,
1578 d->certExpiry.second, 1578 d->certFlags & timeVerified_GmCertFlag ? "Not expired" : "Expired",
1579 d->certFlags & trusted_GmCertFlag ? checked : unchecked, 1579 d->certExpiry.year,
1580 uiText_ColorEscape, 1580 d->certExpiry.month,
1581 d->certFlags & trusted_GmCertFlag ? "Trusted" : "Not trusted"), 1581 d->certExpiry.day,
1582 actionLabels, 1582 d->certExpiry.hour,
1583 actionCmds, 1583 d->certExpiry.minute,
1584 canTrust ? 2 : 1); 1584 d->certExpiry.second,
1585 d->certFlags & trusted_GmCertFlag ? checked : unchecked,
1586 uiText_ColorEscape,
1587 d->certFlags & trusted_GmCertFlag ? "Trusted" : "Not trusted");
1588 iString *fp = collect_String(hexEncode_Block(d->certFingerprint));
1589 if (isEmpty_String(fp)) {
1590 setCStr_String(fp, "(not cached)");
1591 }
1592 else {
1593 insertData_Block(&fp->chars, size_String(fp) / 2, "\n", 1);
1594 }
1595 appendFormat_String(msg,
1596 "\n%sFingerprint:\n%s%s",
1597 uiHeading_ColorEscape,
1598 uiText_ColorEscape,
1599 cstr_String(fp));
1600 appendFormat_String(msg,
1601 "\n%sMedia Type:\n%s%s",
1602 uiHeading_ColorEscape,
1603 uiText_ColorEscape,
1604 cstr_String(meta));
1605 appendFormat_String(msg,
1606 "\n%sContent Length:\n%s%zu",
1607 uiHeading_ColorEscape,
1608 uiText_ColorEscape,
1609 size_Block(&d->sourceContent));
1610 iWidget *dlg = makeQuestion_Widget(uiHeading_ColorEscape "PAGE INFORMATION",
1611 cstr_String(msg),
1612 actionLabels + (canTrust ? 0 : 1),
1613 actionCmds + (canTrust ? 0 : 1),
1614 canTrust ? 3 : 2);
1585 addAction_Widget(dlg, SDLK_ESCAPE, 0, "message.ok"); 1615 addAction_Widget(dlg, SDLK_ESCAPE, 0, "message.ok");
1586 addAction_Widget(dlg, SDLK_SPACE, 0, "message.ok"); 1616 addAction_Widget(dlg, SDLK_SPACE, 0, "message.ok");
1587 return iTrue; 1617 return iTrue;
1588 } 1618 }
1589 else if (equal_Command(cmd, "server.trustcert")) { 1619 else if (equal_Command(cmd, "server.trustcert") && document_App() == d) {
1590 const iRangecc host = urlHost_String(d->mod.url); 1620 const iRangecc host = urlHost_String(d->mod.url);
1591 if (!isEmpty_Block(d->certFingerprint) && !isEmpty_Range(&host)) { 1621 if (!isEmpty_Block(d->certFingerprint) && !isEmpty_Range(&host)) {
1592 setTrusted_GmCerts(certs_App(), host, d->certFingerprint, &d->certExpiry); 1622 setTrusted_GmCerts(certs_App(), host, d->certFingerprint, &d->certExpiry);
1593 d->certFlags |= trusted_GmCertFlag; 1623 d->certFlags |= trusted_GmCertFlag;
1594 postCommand_App("server.showcert"); 1624 postCommand_App("document.info");
1595 } 1625 }
1596 return iTrue; 1626 return iTrue;
1597 } 1627 }
1628 else if (equal_Command(cmd, "server.copycert") && document_App() == d) {
1629 SDL_SetClipboardText(cstrCollect_String(hexEncode_Block(d->certFingerprint)));
1630 return iTrue;
1631 }
1598 else if (equal_Command(cmd, "copy") && document_App() == d && !focus_Widget()) { 1632 else if (equal_Command(cmd, "copy") && document_App() == d && !focus_Widget()) {
1599 iString *copied; 1633 iString *copied;
1600 if (d->selectMark.start) { 1634 if (d->selectMark.start) {
@@ -2530,7 +2564,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2530 if (bannerType_DocumentWidget_(d) == certificateWarning_GmDocumentBanner && 2564 if (bannerType_DocumentWidget_(d) == certificateWarning_GmDocumentBanner &&
2531 pos_Click(&d->click).y - top_Rect(banRect) > 2565 pos_Click(&d->click).y - top_Rect(banRect) >
2532 lineHeight_Text(banner_FontId) * 2) { 2566 lineHeight_Text(banner_FontId) * 2) {
2533 postCommand_App("server.showcert"); 2567 postCommand_App("document.info");
2534 } 2568 }
2535 else { 2569 else {
2536 postCommand_Widget(d, "navigate.root"); 2570 postCommand_Widget(d, "navigate.root");