summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-01-02 11:36:46 +0100
committerYorhel <git@yorhel.nl>2015-01-02 11:36:46 +0100
commitaeb9646445b3cef659ce60b343b38c80015db5c0 (patch)
tree46b317522de866b07152d74582fd208515b7c02a /lib
parente875b3b1602393efc80267651fc5bf2b819e2085 (diff)
staff: Don't allow empty staff revisions
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Func.pm12
-rw-r--r--lib/VNDB/Handler/Staff.pm1
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 3b315c93..ac9fdd58 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -204,16 +204,18 @@ sub fmtvote {
}
-my $JSON; # cache
+# JSON::XS::encode_json converts input to utf8, whereas the below functions
+# operate on wide character strings. Canonicalization is enabled to allow for
+# proper comparison of serialized objects.
+my $JSON = JSON::XS->new;
+$JSON->canonical(1);
-# JSON::XS::encode_json converts input to utf8, whereas these functions
-# operate on wide character strings.
sub jsonEncode ($) {
- ($JSON ||= JSON::XS->new)->encode(@_);
+ $JSON->encode(@_);
}
sub jsonDecode ($) {
- ($JSON ||= JSON::XS->new)->decode(@_);
+ $JSON->decode(@_);
}
# Insert JSON-encoded data as script, arguments: id, object
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index 4e319b3f..9b9d677c 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -225,6 +225,7 @@ sub edit {
push @{$frm->{_err}}, [ 'aliases', 'template', 'json' ] if $@;
if(!$frm->{_err}) {
for my $a (@$aliases) {
+ $a->{aid} *= 1; # normalize to a number so that the comparison works.
# check for empty aliases
if($a->{name} =~ /^\s*$/) {
push @{$frm->{_err}}, ['alias_name', 'required'];