]> git.eshelyaron.com Git - emacs.git/commit
gnus-shorten-url: Improve and avoid args-out-of-range error
authorŠtěpán Němec <stepnem@gmail.com>
Sat, 7 Mar 2020 17:26:44 +0000 (18:26 +0100)
committerŠtěpán Němec <stepnem@gmail.com>
Mon, 13 Apr 2020 10:12:00 +0000 (12:12 +0200)
commit188bd80a903d34ef6a85b09e99890433e7adceb7
treef8f32f801fcf61e0a4464bee9319c1ecc78e8943
parentc395ebaf2142b4a142262353f730fb7b1fcea710
gnus-shorten-url: Improve and avoid args-out-of-range error

'gnus-shorten-url' (used by 'gnus-summary-browse-url') ignored
fragment identifiers and didn't check substring bounds, in some cases
leading to runtime errors, e.g.:

  (gnus-shorten-url "https://some.url.with/path/and#also_a_long_target" 40)
  ;; => Lisp error: (args-out-of-range "/path/and" -18 nil)

This commit makes it account for #fragments and fixes faulty string
computation, reusing existing helper function.  (bug#39980)

* lisp/vc/ediff-init.el (ediff-truncate-string-left): Rename to
'string-truncate-left' and move...
* lisp/emacs-lisp/subr-x.el (string-truncate-left):  ...here.
All callers changed.
* lisp/gnus/gnus-sum.el (gnus-shorten-url): Fix args-out-of-range
error, don't drop #fragments, use 'string-truncate-left'.
lisp/emacs-lisp/subr-x.el
lisp/gnus/gnus-sum.el
lisp/vc/ediff-init.el
lisp/vc/ediff-mult.el