summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-01-12 15:32:45 +0100
committerYorhel <git@yorhel.nl>2018-01-12 15:32:47 +0100
commit0dfcad1921d1f20e51ebb5dc6d07e330367f3631 (patch)
tree7d421cd1f0666950885dc6e8586641cb63226d76 /lib
parent5c31c5f1629709ce337626cd0dfa216adf3828a4 (diff)
Don't allow unlikely short GTIN codes
Should fix https://vndb.org/t2520.237
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/VN.pm2
-rw-r--r--lib/VNDB/Handler/Releases.pm2
-rw-r--r--lib/VNDBUtil.pm1
3 files changed, 3 insertions, 2 deletions
diff --git a/lib/VNDB/DB/VN.pm b/lib/VNDB/DB/VN.pm
index 55464728..5412ed2a 100644
--- a/lib/VNDB/DB/VN.pm
+++ b/lib/VNDB/DB/VN.pm
@@ -6,7 +6,7 @@ use warnings;
use TUWF 'sqlprint';
use POSIX 'strftime';
use Exporter 'import';
-use VNDB::Func 'gtintype', 'normalize_query';
+use VNDB::Func 'normalize_query';
our @EXPORT = qw|dbVNGet dbVNGetRev dbVNRevisionInsert dbVNImageId dbScreenshotAdd dbScreenshotGet dbScreenshotRandom dbVNImportSeiyuu|;
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 3181566e..2e058fb6 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -217,7 +217,7 @@ sub _infotable {
if($r->{gtin}) {
Tr;
- td gtintype $r->{gtin};
+ td gtintype($r->{gtin}) || 'GTIN';
td $r->{gtin};
end;
}
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm
index c8cd1bc1..a534856f 100644
--- a/lib/VNDBUtil.pm
+++ b/lib/VNDBUtil.pm
@@ -23,6 +23,7 @@ sub shorten {
# Also 'normalizes' the first argument in place
sub gtintype {
$_[0] =~ s/[^\d]+//g;
+ return undef if $_[0] !~ /^[0-9]{10,13}$/; # I've yet to see a UPC code shorter than 10 digits assigned to a game
$_[0] = ('0'x(12-length $_[0])) . $_[0] if length($_[0]) < 12; # pad with zeros to GTIN-12
my $c = shift;
return undef if $c !~ /^[0-9]{12,13}$/;