all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] ERC: Hide identification password sent to Nickserv
@ 2015-03-15  9:53 vibhavp
  2015-03-15 10:09 ` Vibhav Pant
  2015-03-17  1:10 ` vibhavp
  0 siblings, 2 replies; 5+ messages in thread
From: vibhavp @ 2015-03-15  9:53 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

Hello,
I've added a feature to Emacs which hides the password sent to nickserv
for nick identification by changing the password's "display" test
property with a dotted string. Here's an example:
ERC> /msg nickserv identify foobar
When sent to ERC, the ERC buffer displays this as:
ERC> /msg nickserv identify .....
I've also added this to the default list of modules, so passwords are
hidden by default. Feel free to point out anything wrong in the
attached patch.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: erc-passwd-hide.patch --]
[-- Type: text/x-diff, Size: 2491 bytes --]

diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog
index 4f5fced..bbdb74e 100644
--- a/lisp/erc/ChangeLog
+++ b/lisp/erc/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-15  Vibhav Pant  <vibhavp@gmail.com>
+
+	* erc-goodies.el (erc-hide-ident-password): New function.
+	(hide-nickserv-password): New module.
+	* erc-el: Add hide-nickserv-password to erc-modules.
+
 2015-03-03  Kelvin White  <kwhite@gnu.org>
 
 	* erc.el: Add old version string back to file header for
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index ca2d14a..84f7f1f 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -550,6 +550,27 @@ See also `unmorse-region'."
       ;; Unmorse region
       (unmorse-region (point-min) (point-max)))))
 
+;; Hide Nickserv identify password
+(define-erc-module hide-nickserv-password nil
+  "This mode hides the identify password sent to Nickserv.
+It replaces each character of the password with '.'"
+  ((add-hook 'erc-send-modify-hook 'erc-hide-ident-password))
+  ((remove-hook 'erc-send-modify-hook 'erc-hide-ident-password)))
+
+(defun erc-hide-ident-password ()
+  "Hide the identification password sent to Nickserv.
+Search the buffer for any identification requests to Nickserv, and
+sets the display text property of the password to a dotted string."
+  (save-excursion
+    (with-current-buffer (current-buffer)
+      (goto-char (point-min))
+      (when (re-search-forward "/\\(msg\\|query\\) nickserv identify "
+			       nil t nil)
+	(let ((bounds (bounds-of-thing-at-point 'word)))
+	  (put-text-property (car bounds) (cdr bounds) 'display
+			     (make-string
+			      (- (cdr bounds) (car bounds)) ?.)))))))
+
 ;;; erc-occur
 (defun erc-occur (string &optional proc)
   "Search for STRING in all buffers related to current server.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index a84f9f0..bfbceae 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1810,7 +1810,8 @@ buffer rather than a server buffer.")
 
 (defcustom erc-modules '(netsplit fill button match track completion readonly
                                   networks ring autojoin noncommands irccontrols
-                                  move-to-prompt stamp menu list)
+                                  move-to-prompt stamp menu list
+				  hide-nickserv-password)
   "A list of modules which ERC should enable.
 If you set the value of this without using `customize' remember to call
 \(erc-update-modules) after you change it.  When using `customize', modules

[-- Attachment #3: Type: text/plain, Size: 43 bytes --]


Thanks.
-- 
Vibhav Pant
vibhavp@gmail.com

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-17 21:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-15  9:53 [PATCH] ERC: Hide identification password sent to Nickserv vibhavp
2015-03-15 10:09 ` Vibhav Pant
2015-03-17  1:10 ` vibhavp
2015-03-16 20:02   ` Kelvin White
2015-03-17 21:56     ` Kelvin White

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.