File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -1062,8 +1062,7 @@ def padright_fn(
10621062 """Implements the padright parser function."""
10631063 v = expander (args [0 ]) if args else ""
10641064 cntstr = expander (args [1 ]).strip () if len (args ) >= 2 else "0"
1065- arg2 = expander (args [2 ]) if len (args ) >= 3 and args [2 ] else "0"
1066- pad = arg2 if len (args ) >= 3 and arg2 else "0"
1065+ pad = expander (args [2 ]) if len (args ) >= 3 else "0"
10671066 if not cntstr .isdigit ():
10681067 cnt = 0
10691068 if cntstr .startswith ("-" ) and cntstr [1 :].isdigit ():
@@ -1075,7 +1074,7 @@ def padright_fn(
10751074 )
10761075 else :
10771076 cnt = int (cntstr )
1078- if cnt - len (v ) > len (pad ):
1077+ if cnt - len (v ) > len (pad ) and len ( pad ) > 0 :
10791078 pad = pad * ((cnt - len (v )) // len (pad ))
10801079 if len (v ) < cnt :
10811080 v = v + pad [: cnt - len (v )]
Original file line number Diff line number Diff line change @@ -214,3 +214,8 @@ def test_padleft_zero_division(self):
214214 self .wtp .start_page ("land" )
215215 self .assertEqual (self .wtp .expand ("{{padleft:|1|}}" ), "" )
216216 self .assertEqual (self .wtp .expand ("{{padleft:|1}}" ), "0" )
217+
218+ def test_padright_zero_division (self ):
219+ self .wtp .start_page ("land" )
220+ self .assertEqual (self .wtp .expand ("{{padright:|1|}}" ), "" )
221+ self .assertEqual (self .wtp .expand ("{{padright:|1}}" ), "0" )
You can’t perform that action at this time.
0 commit comments