--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -344,10 +387,20 @@ word(s) will be searched for via `eww-search-prefix'."
     (setq header-line-format nil)))
 
 (defun eww-tag-title (cont)
-  (setq eww-current-title "")
-  (dolist (sub cont)
-    (when (eq (car sub) 'text)
-      (setq eww-current-title (concat eww-current-title (cdr sub)))))
+  (setq eww-current-title
+	(with-temp-buffer
+	  (dolist (sub cont)
+	    (when (eq (car sub) 'text)
+	      (insert (cdr sub))))
+	  ;; trim leading and trailing whitespace
+	  (goto-char (point-min))
+	  (when (re-search-forward "^[[:blank:]\r\n]+" nil t)
+	    (replace-match ""))
+	  (goto-char (point-max))
+	  (when (re-search-backward "[[:blank:]\r\n]+$" nil t)
+	    (replace-match ""))
+	  ;; .
+	  (buffer-string)))
   (eww-update-header-line-format))
 
 (defun eww-tag-body (cont)
@@ -1303,23 +1370,29 @@ Differences in #targets are ignored."
 	(setq start (point))
 	(setq domain-length (max domain-length (length (plist-get history :url))))
 	(setq title-length (max title-length (length (plist-get history :title)))))
-      (setq format (format "%%-%ds %%-%ds" title-length domain-length)
+      (setq format (format "%%-%ds %%s" title-length)
 	    header-line-format
 	    (concat " " (format format "Title" "URL")))
       (dolist (history eww-history-trans)
 	(setq start (point))
 	(setq url (plist-get history :url))
-	(setq title (plist-get history :title))
+	(with-temp-buffer
+	  (insert (plist-get history :title))
+	  (goto-char (point-min))
+	  (while (re-search-forward "[\000-\037]" nil t)
+	    (replace-match
+	     (string ?^ (logior ?@ (aref (match-string 0) 0)))))
+	  (setq title (buffer-string)))
 	(insert (format format title url))
 	(insert "\n")
-	(put-text-property start (1+ start) 'eww-history history))
+	(put-text-property start (point) 'eww-history history))
       (goto-char (point-min)))
     (pop-to-buffer "*eww history*")))
 
 (defun eww-history-browse ()
   "Browse the history under point in eww."
   (interactive)
-  (let ((history (get-text-property (line-beginning-position) 'eww-history)))
+  (let ((history (get-text-property (point) 'eww-history)))
     (unless history
       (error "No history on the current line"))
     (quit-window)
