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(
1062
1062
"""Implements the padright parser function."""
1063
1063
v = expander (args [0 ]) if args else ""
1064
1064
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"
1067
1066
if not cntstr .isdigit ():
1068
1067
cnt = 0
1069
1068
if cntstr .startswith ("-" ) and cntstr [1 :].isdigit ():
@@ -1075,7 +1074,7 @@ def padright_fn(
1075
1074
)
1076
1075
else :
1077
1076
cnt = int (cntstr )
1078
- if cnt - len (v ) > len (pad ):
1077
+ if cnt - len (v ) > len (pad ) and len ( pad ) > 0 :
1079
1078
pad = pad * ((cnt - len (v )) // len (pad ))
1080
1079
if len (v ) < cnt :
1081
1080
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):
214
214
self .wtp .start_page ("land" )
215
215
self .assertEqual (self .wtp .expand ("{{padleft:|1|}}" ), "" )
216
216
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