⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

flexigrid's "Search" string get garbled with multibyte string



Kenta Saito

Kenta Saito
  • profile picture
  • Member

Posted 19 March 2012 - 14:35 PM

Version:
grocery_CRUD_v1.2.zip

Symptom:
flexigrid's "Search" string get garbled with multibyte string.
(after page transition)

Fix:
Apply escape() and unescape() to Cookie.
* Table definition must be utf8.

Suggestion:

diff -ru --strip-trailing-cr CodeIgniter_2.1.0.orig/assets/grocery_crud/themes/flexigrid/js/cookies.js CodeIgniter_2.1.0/assets/grocery_crud/themes/flexigrid/js/cookies.js
--- CodeIgniter_2.1.0.orig/assets/grocery_crud/themes/flexigrid/js/cookies.js 2012-03-15 21:27:32.000000000 +0900
+++ CodeIgniter_2.1.0/assets/grocery_crud/themes/flexigrid/js/cookies.js 2012-03-19 22:52:02.000000000 +0900
@@ -5,7 +5,7 @@
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
- document.cookie = name+"="+value+expires+"; path=/";
+ document.cookie = name+"="+escape(value)+expires+"; path=/";
}
function readCookie(name) {
@@ -15,7 +15,7 @@
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0)
- return c.substring(nameEQ.length,c.length);
+ return unescape(c.substring(nameEQ.length,c.length));
}
return null;
}
diff -ru --strip-trailing-cr CodeIgniter_2.1.0.orig/example_database.sql CodeIgniter_2.1.0/example_database.sql
--- CodeIgniter_2.1.0.orig/example_database.sql 2012-03-15 21:27:32.000000000 +0900
+++ CodeIgniter_2.1.0/example_database.sql 2012-03-19 22:56:46.000000000 +0900
@@ -284,7 +284,7 @@
`salesRepEmployeeNumber` int(11) DEFAULT NULL,
`creditLimit` double DEFAULT NULL,
PRIMARY KEY (`customerNumber`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=497 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=497 ;
--
-- Dumping data for table `customers`
@@ -430,7 +430,7 @@
`file_url` varchar(250) CHARACTER SET utf8 NOT NULL,
`jobTitle` varchar(50) NOT NULL,
PRIMARY KEY (`employeeNumber`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1703 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1703 ;
--
-- Dumping data for table `employees`
@@ -9023,7 +9023,7 @@
`postalCode` varchar(15) NOT NULL,
`territory` varchar(10) NOT NULL,
PRIMARY KEY (`officeCode`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ;
--
-- Dumping data for table `offices`
@@ -9051,7 +9051,7 @@
`priceEach` double NOT NULL,
`orderLineNumber` smallint(6) NOT NULL,
PRIMARY KEY (`orderNumber`,`productCode`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `orderdetails`
@@ -12072,7 +12072,7 @@
`comments` text,
`customerNumber` int(11) NOT NULL,
PRIMARY KEY (`orderNumber`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10426 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10426 ;
--
-- Dumping data for table `orders`
@@ -12418,7 +12418,7 @@
`paymentDate` datetime NOT NULL,
`amount` double NOT NULL,
PRIMARY KEY (`customerNumber`,`checkNumber`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `payments`
@@ -12711,7 +12711,7 @@
`htmlDescription` mediumtext,
`image` mediumblob,
PRIMARY KEY (`productLine`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `productlines`
@@ -12743,7 +12743,7 @@
`buyPrice` double NOT NULL,
`MSRP` double NOT NULL,
PRIMARY KEY (`productCode`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `products`

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 20 March 2012 - 07:25 AM

Thank you very much [member='Kenta Saito'] . I will add it to grocery CRUD.

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 08 April 2012 - 16:05 PM

Just add this fix to the master https://github.com/scoumbourdis/grocery-crud/issues/16

Thank you again.

Kenta Saito

Kenta Saito
  • profile picture
  • Member

Posted 09 April 2012 - 06:10 AM

Johnny, thank you for your management too.
Your words cheer members up!