summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-12-09 16:54:56 +0100
committerYorhel <git@yorhel.nl>2010-12-09 16:54:56 +0100
commit4f91b0b1229e3037f2937acf3e4ec994f33de4f4 (patch)
treeb71940eb74dd979bbb4dff679d921c88db6c25e3
parent72dd32c56b944d207dc70cbe4fc37f8298bd4366 (diff)
Write VNDBUtil::uri_escape() and removed dependency on URI::Escape
Its functionality is too simpel to require it as a special dependency, seriously.
-rw-r--r--README1
-rw-r--r--lib/Multi/IRC.pm7
-rw-r--r--lib/VNDBUtil.pm12
3 files changed, 14 insertions, 6 deletions
diff --git a/README b/README
index 635ae02d..fc70f650 100644
--- a/README
+++ b/README
@@ -39,7 +39,6 @@ Requirements
XML::Writer
IRC:
POE::Component::IRC
- URI::Escape
Image:
Image::Magick
Maintenance:
diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm
index 75b4f7c4..d2fa1757 100644
--- a/lib/Multi/IRC.pm
+++ b/lib/Multi/IRC.pm
@@ -14,9 +14,8 @@ use POE qw|
Component::IRC::Plugin::Logger
|;
use POE::Component::IRC::Common ':ALL';
-use URI::Escape 'uri_escape_utf8';
use Time::HiRes 'time';
-use VNDBUtil 'normalize_query';
+use VNDBUtil 'normalize_query', 'uri_escape';
use constant {
@@ -370,7 +369,7 @@ sub cmd_vn {
sub cmd_vn_results { # num, res, \@_
return $_[KERNEL]->yield(reply => $_[ARG2][DEST], 'No visual novels found', $_[ARG2][USER]) if $_[ARG0] < 1;
return $_[KERNEL]->yield(reply => $_[ARG2][DEST], sprintf(
- 'Too many results found, see %s/v/all?q=%s', $VNDB::S{url}, uri_escape_utf8($_[ARG2][ARG])
+ 'Too many results found, see %s/v/all?q=%s', $VNDB::S{url}, uri_escape($_[ARG2][ARG])
), $_[ARG2][USER]) if $_[ARG0] > 5;
$_[KERNEL]->yield(formatid => $_[ARG0], $_[ARG1], [$_[ARG2][DEST]]);
}
@@ -395,7 +394,7 @@ sub cmd_p {
sub cmd_p_results { # num, res, \@_
return $_[KERNEL]->yield(reply => $_[ARG2][DEST], 'No producers found', $_[ARG2][USER]) if $_[ARG0] < 1;
return $_[KERNEL]->yield(reply => $_[ARG2][DEST], sprintf(
- 'Too many results found, see %s/p/all?q=%s', $VNDB::S{url}, uri_escape_utf8($_[ARG2][ARG])
+ 'Too many results found, see %s/p/all?q=%s', $VNDB::S{url}, uri_escape($_[ARG2][ARG])
), $_[ARG2][USER]) if $_[ARG0] > 5;
$_[KERNEL]->yield(formatid => $_[ARG0], $_[ARG1], [$_[ARG2][DEST]]);
}
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm
index b0213d07..36038d47 100644
--- a/lib/VNDBUtil.pm
+++ b/lib/VNDBUtil.pm
@@ -5,9 +5,10 @@ package VNDBUtil;
use strict;
use warnings;
use Exporter 'import';
+use Encode 'encode_utf8';
use Unicode::Normalize 'NFKD';
-our @EXPORT = qw|shorten bb2html gtintype normalize normalize_titles normalize_query imgsize|;
+our @EXPORT = qw|shorten bb2html gtintype normalize normalize_titles normalize_query imgsize uri_escape|;
sub shorten {
@@ -240,5 +241,14 @@ sub imgsize {
}
+# Same as URI::Escape::uri_escape_utf8(), only simpler and doesn't add extra
+# dependencies
+sub uri_escape {
+ local $_ = encode_utf8 shift;
+ s/([^A-Za-z0-9._~-])/sprintf '%%%02X', ord $1/eg;
+ return $_;
+}
+
+
1;