[Slashdotjp-dev 666] [169] Apply hex encode for binary columns.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2007年 8月 24日 (金) 21:51:44 JST


Revision: 169
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=slashdotjp&view=rev&rev=169
Author:   sugi
Date:     2007-08-24 21:51:43 +0900 (Fri, 24 Aug 2007)

Log Message:
-----------
Apply hex encode for binary columns.

Modified Paths:
--------------
    slashjp/trunk/Slash/DB/MySQL/MySQL.pm
    slashjp/trunk/debian/changelog
    slashjp/trunk/plugins/Blob/Blob.pm
    slashjp/trunk/plugins/Messages/DB/MySQL/MySQL.pm


-------------- next part --------------
Modified: slashjp/trunk/Slash/DB/MySQL/MySQL.pm
===================================================================
--- slashjp/trunk/Slash/DB/MySQL/MySQL.pm	2007-07-23 05:00:55 UTC (rev 168)
+++ slashjp/trunk/Slash/DB/MySQL/MySQL.pm	2007-08-24 12:51:43 UTC (rev 169)
@@ -311,10 +311,9 @@
 # Perl has lost the flag somewhere
 sub sqlDo{
 	my($self, $sql) = @_;
-	$sql = decode_utf8( $sql ) unless $sql =~ /INSERT\s+INTO\s+accesslog_admin|UPDATE\s+users_info\s+SET\s+people\s+=/;
-	$self->SUPER::sqlDo( $sql );
+	$self->SUPER::sqlDo(decode_utf8($sql));
 }
-  
+
 ########################################################
 # Yes, this is ugly, and we can ditch it in about 6 months
 # Turn off autocommit here
@@ -2168,7 +2167,7 @@
 		skid		=> $skid,
 		bytes		=> $r->bytes_sent,
 		op		=> $op,
-		form		=> $form_freeze ? $self->truncateStringForCharColumn($form_freeze, 'accesslog_admin', 'form') : '',
+		-form		=> $form_freeze ? "0x" . unpack("H*", $self->truncateStringForCharColumn($form_freeze, 'accesslog_admin', 'form')) : '',
 		-ts		=> 'NOW()',
 		query_string	=> $ENV{QUERY_STRING} ? $self->truncateStringForCharColumn($ENV{QUERY_STRING}, 'accesslog_admin', 'query_string') : '0',
 		user_agent	=> $ENV{HTTP_USER_AGENT} ? $self->truncateStringForCharColumn($ENV{HTTP_USER_AGENT}, 'accesslog_admin', 'user_agent') : 'undefined',
@@ -11837,7 +11836,10 @@
 		$hashref->{newpasswd} = '';
 		$hashref->{passwd} = encryptPassword($hashref->{passwd});
 	}
-	$hashref->{people} = freeze($hashref->{people}) if $hashref->{people};
+	if ($hashref->{people}) {
+		$hashref->{"-people"} = "0x" . unpack("H*", freeze($hashref->{people}));
+		delete($hashref->{people});
+	}
 	if (exists $hashref->{slashboxes}) {
 		my @slashboxes = grep /^[\w-]+$/, split /,/, $hashref->{slashboxes};
 		$hashref->{slashboxes} = join ",", @slashboxes;

Modified: slashjp/trunk/debian/changelog
===================================================================
--- slashjp/trunk/debian/changelog	2007-07-23 05:00:55 UTC (rev 168)
+++ slashjp/trunk/debian/changelog	2007-08-24 12:51:43 UTC (rev 169)
@@ -1,3 +1,9 @@
+slash (2.5.0.119-16) unstable; urgency=low
+
+  * Hex encoding was applied for all binary columns.
+
+ -- Tatsuki Sugiura <sugi****@nemui*****>  Mon, 23 Jul 2007 13:59:15 +0900
+
 slash (2.5.0.119-15) unstable; urgency=low
 
   * admin.pl: fix regex to pick up related stories and comments, again.

Modified: slashjp/trunk/plugins/Blob/Blob.pm
===================================================================
--- slashjp/trunk/plugins/Blob/Blob.pm	2007-07-23 05:00:55 UTC (rev 168)
+++ slashjp/trunk/plugins/Blob/Blob.pm	2007-08-24 12:51:43 UTC (rev 169)
@@ -88,7 +88,7 @@
 		my $base = 1024**2;  # 1MB
 		if ($len > $base) {
 			$value = $self->sqlGetVar($var);
-			my $needed = $len + $base;
+			my $needed = $len*2+2 + $base;
 
 			if ($value < $needed) {
 				return unless $self->sqlSetVar($var, $needed*2);
@@ -113,13 +113,16 @@
 					$size = $base >= $value ? $base/2 : $base; 
 					$data = $values->{data};
 					$values->{data} = substr($data, 0, $size, '');
+					$values->{"-data"} = "0x" . unpack('H*', $values->{data});
+					delete($values->{data});
 				}
 
 				$self->sqlInsert($table, $values) or return undef;
 
 				if ($do_chunk) {
 					while (length $data) {
-						my $chunk = $self->sqlQuote(substr($data, 0, $size, ''));
+						#my $chunk = $self->sqlQuote(substr($data, 0, $size, ''));
+						my $chunk = "0x" . unpack('H*', substr($data, 0, $size, ''));
 						my $ok = $self->sqlUpdate($table, {
 								-data => "CONCAT(data, $chunk)"
 							}, $where
@@ -143,6 +146,9 @@
 
 		# true $value means we already saved the data
 		unless ($value) {
+			$values->{"-data"} = "0x" . unpack("H*", $values->{data});
+			delete($values->{data});
+
 			$self->sqlInsert($table, $values) or return undef;
 		}
 

Modified: slashjp/trunk/plugins/Messages/DB/MySQL/MySQL.pm
===================================================================
--- slashjp/trunk/plugins/Messages/DB/MySQL/MySQL.pm	2007-07-23 05:00:55 UTC (rev 168)
+++ slashjp/trunk/plugins/Messages/DB/MySQL/MySQL.pm	2007-08-24 12:51:43 UTC (rev 169)
@@ -195,7 +195,7 @@
 		fuser	=> $fuser,
 		altto	=> $altto || '',
 		code	=> $code,
-		message	=> $frozen,
+		'-message' => "0x" . unpack("H*", $frozen),
 		'send'	=> $send || 'now',
 	});
 


Slashdotjp-dev メーリングリストの案内
Back to archive index