From 4995165edcb08e2f364bfc7fc42d2f65bcd069c0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 12 Jul 2009 14:47:50 +0200 Subject: Simplestore: Allow only \w+ key names --- lib/Simplestore.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Simplestore.pm b/lib/Simplestore.pm index 11d8058..35c94e2 100644 --- a/lib/Simplestore.pm +++ b/lib/Simplestore.pm @@ -37,6 +37,9 @@ sub save { my $key; open(my $handle, '>', $file) or confess("Cannot open $file: $!"); foreach $key (keys(%$store)) { + if ($key !~ /^\w+$/) { + confess("Invalid key name: May only contain alphanumeric and _"); + } foreach (split(/\n/, $store->{$key})) { print $handle "$key\t$_\n"; } @@ -78,8 +81,9 @@ Simplestore - simple storage format for hash refs B is a perl library to store hashes in a very simple, easy-to-parse file format. -Note that it can only store simple hashes with string/digit values. -References or any other complex stuff is not supported. +Note that it can only store simple hashes with string/digit values and +word keys (the key must match \w+, like a perl variable name for example). +References or any other complex stuff are not supported. =head1 FUNCTIONS -- cgit v1.2.3