##// END OF EJS Templates
alias: reject non-ascii characters in user help/doc strings...
Yuya Nishihara -
r37157:aa55c535 default
parent child Browse files
Show More
@@ -534,12 +534,24 b' class cmdalias(object):'
534 % (self.name, cmd))
534 % (self.name, cmd))
535
535
536 def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None):
536 def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None):
537 self.help = ui.config('alias', '%s:help' % name, defaulthelp or '')
537 # confine strings to be passed to i18n.gettext()
538 cfg = {}
539 for k in ('doc', 'help'):
540 v = ui.config('alias', '%s:%s' % (name, k), None)
541 if v is None:
542 continue
543 if not encoding.isasciistr(v):
544 self.badalias = (_("non-ASCII character in alias definition "
545 "'%s:%s'") % (name, k))
546 return
547 cfg[k] = v
548
549 self.help = cfg.get('help', defaulthelp or '')
538 if self.help and self.help.startswith("hg " + cmd):
550 if self.help and self.help.startswith("hg " + cmd):
539 # drop prefix in old-style help lines so hg shows the alias
551 # drop prefix in old-style help lines so hg shows the alias
540 self.help = self.help[4 + len(cmd):]
552 self.help = self.help[4 + len(cmd):]
541
553
542 self.__doc__ = ui.config('alias', '%s:doc' % name, fn.__doc__)
554 self.__doc__ = cfg.get('doc', fn.__doc__)
543
555
544 @property
556 @property
545 def args(self):
557 def args(self):
@@ -616,6 +616,25 b' help for a shell alias'
616
616
617 (some details hidden, use --verbose to show complete help)
617 (some details hidden, use --verbose to show complete help)
618
618
619 invalid character in user-specified help
620
621 >>> with open('.hg/hgrc', 'ab') as f:
622 ... f.write(b'[alias]\n'
623 ... b'invaliddoc = log\n'
624 ... b'invaliddoc:doc = \xc0\n'
625 ... b'invalidhelp = log\n'
626 ... b'invalidhelp:help = \xc0\n') and None
627 $ hg help invaliddoc
628 non-ASCII character in alias definition 'invaliddoc:doc'
629 $ hg help invalidhelp
630 non-ASCII character in alias definition 'invalidhelp:help'
631 $ hg invaliddoc
632 abort: non-ASCII character in alias definition 'invaliddoc:doc'
633 [255]
634 $ hg invalidhelp
635 abort: non-ASCII character in alias definition 'invalidhelp:help'
636 [255]
637
619 invalid arguments
638 invalid arguments
620
639
621 $ hg rt foo
640 $ hg rt foo
General Comments 0
You need to be logged in to leave comments. Login now