commit e68a3ba13f1761bb51f04820c38e0e1a0c03c947
parent 7f4a32404901c07bce2b3a3b308617560097cde0
Author: Chris Bracken <chris@bracken.jp>
Date: Thu, 6 Jan 2022 20:52:44 -0800
Stricter filename regular expressions
Ensure we match from the beginning to the end of the filename.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/convert/convert.go b/convert/convert.go
@@ -41,7 +41,7 @@ func (c *RbcDirectInvesting) Type() string {
}
func (c *RbcDirectInvesting) CanConvert(fname string) bool {
- r := regexp.MustCompile(`\d+-\d{4}[A-Za-z]{3}\d\d-\d{4}[A-Za-z]{3}\d\d`)
+ r := regexp.MustCompile(`^\d+-\d{4}[A-Za-z]{3}\d\d-\d{4}[A-Za-z]{3}\d\d\.pdf$`)
return r.MatchString(fname)
}
@@ -87,7 +87,7 @@ func (c *ShinseiBank) Type() string {
func (c *ShinseiBank) CanConvert(fname string) bool {
// TODO: this will break in the year 3000.
// Even more terrifying if we're still using PDFs.
- r := regexp.MustCompile(`2\d{15}\.pdf`)
+ r := regexp.MustCompile(`^2\d{15}\.pdf$`)
return r.MatchString(strings.ToLower(fname))
}