diff options
| author | Eli Zaretskii | 2023-09-08 15:11:10 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-09-08 15:11:10 +0300 |
| commit | 7572620da292d5e4ab5ca9a24cd9b4b853f035eb (patch) | |
| tree | e8da1f7b713d5a3deed9286fbab662efd65b4bd9 | |
| parent | b076aa723909f63f24b818a5d2988c3c5c0de4a8 (diff) | |
| download | emacs-7572620da292d5e4ab5ca9a24cd9b4b853f035eb.tar.gz emacs-7572620da292d5e4ab5ca9a24cd9b4b853f035eb.zip | |
Avoid errors in EWW when EWW is killed
* lisp/net/eww.el (eww-render): Don't signal errors if the page
being rendered was closed. (Bug#65678)
| -rw-r--r-- | lisp/net/eww.el | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 089e481ead2..4ddda216afc 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -620,46 +620,49 @@ The renaming scheme is performed in accordance with | |||
| 620 | (let ((redirect (plist-get status :redirect))) | 620 | (let ((redirect (plist-get status :redirect))) |
| 621 | (when redirect | 621 | (when redirect |
| 622 | (setq url redirect))) | 622 | (setq url redirect))) |
| 623 | (with-current-buffer buffer | 623 | (when (buffer-live-p buffer) |
| 624 | ;; Save the https peer status. | 624 | (with-current-buffer buffer |
| 625 | (plist-put eww-data :peer (plist-get status :peer)) | 625 | ;; Save the https peer status. |
| 626 | ;; Make buffer listings more informative. | 626 | (plist-put eww-data :peer (plist-get status :peer)) |
| 627 | (setq list-buffers-directory url) | 627 | ;; Make buffer listings more informative. |
| 628 | ;; Let the URL library have a handle to the current URL for | 628 | (setq list-buffers-directory url) |
| 629 | ;; referer purposes. | 629 | ;; Let the URL library have a handle to the current URL for |
| 630 | (setq url-current-lastloc (url-generic-parse-url url))) | 630 | ;; referer purposes. |
| 631 | (unwind-protect | 631 | (setq url-current-lastloc (url-generic-parse-url url))) |
| 632 | (progn | 632 | (unwind-protect |
| 633 | (cond | 633 | (progn |
| 634 | ((and eww-use-external-browser-for-content-type | 634 | (cond |
| 635 | (string-match-p eww-use-external-browser-for-content-type | 635 | ((and eww-use-external-browser-for-content-type |
| 636 | (car content-type))) | 636 | (string-match-p eww-use-external-browser-for-content-type |
| 637 | (erase-buffer) | 637 | (car content-type))) |
| 638 | (insert "<title>Unsupported content type</title>") | 638 | (erase-buffer) |
| 639 | (insert (format "<h1>Content-type %s is unsupported</h1>" | 639 | (insert "<title>Unsupported content type</title>") |
| 640 | (car content-type))) | 640 | (insert (format "<h1>Content-type %s is unsupported</h1>" |
| 641 | (insert (format "<a href=%S>Direct link to the document</a>" | 641 | (car content-type))) |
| 642 | url)) | 642 | (insert (format "<a href=%S>Direct link to the document</a>" |
| 643 | (goto-char (point-min)) | 643 | url)) |
| 644 | (eww-display-html charset url nil point buffer encode)) | 644 | (goto-char (point-min)) |
| 645 | ((eww-html-p (car content-type)) | 645 | (eww-display-html charset url nil point buffer encode)) |
| 646 | (eww-display-html charset url nil point buffer encode)) | 646 | ((eww-html-p (car content-type)) |
| 647 | ((equal (car content-type) "application/pdf") | 647 | (eww-display-html charset url nil point buffer encode)) |
| 648 | (eww-display-pdf)) | 648 | ((equal (car content-type) "application/pdf") |
| 649 | ((string-match-p "\\`image/" (car content-type)) | 649 | (eww-display-pdf)) |
| 650 | (eww-display-image buffer)) | 650 | ((string-match-p "\\`image/" (car content-type)) |
| 651 | (t | 651 | (eww-display-image buffer)) |
| 652 | (eww-display-raw buffer (or encode charset 'utf-8)))) | 652 | (t |
| 653 | (with-current-buffer buffer | 653 | (eww-display-raw buffer (or encode charset 'utf-8)))) |
| 654 | (plist-put eww-data :url url) | 654 | (with-current-buffer buffer |
| 655 | (eww--after-page-change) | 655 | (plist-put eww-data :url url) |
| 656 | (setq eww-history-position 0) | 656 | (eww--after-page-change) |
| 657 | (and last-coding-system-used | 657 | (setq eww-history-position 0) |
| 658 | (set-buffer-file-coding-system last-coding-system-used)) | 658 | (and last-coding-system-used |
| 659 | (run-hooks 'eww-after-render-hook) | 659 | (set-buffer-file-coding-system last-coding-system-used)) |
| 660 | ;; Enable undo again so that undo works in text input | 660 | (run-hooks 'eww-after-render-hook) |
| 661 | ;; boxes. | 661 | ;; Enable undo again so that undo works in text input |
| 662 | (setq buffer-undo-list nil))) | 662 | ;; boxes. |
| 663 | (setq buffer-undo-list nil))) | ||
| 664 | (kill-buffer data-buffer))) | ||
| 665 | (unless (buffer-live-p buffer) | ||
| 663 | (kill-buffer data-buffer)))) | 666 | (kill-buffer data-buffer)))) |
| 664 | 667 | ||
| 665 | (defun eww-parse-headers () | 668 | (defun eww-parse-headers () |