Bug 15684: Fix encoding issues with quote upload

To verify:
- Download attachment 'Goethe with umlaut' from Bug 15684
- Go to Tools > Quote Editor
- Click "Import quotes" and select the file
- The quotes display in a table. Click 'Sav quotes'
- Result: Nothing happens

To test:
- Apply patch
- Repeat steps above
- Verify that you get a message '2 quotes saved' and that the quotes
  are added in to the quotes table
- Test with attachment 'sample quotes' as well

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
This commit is contained in:
Marc Véron 2016-01-28 22:05:58 +01:00 committed by Brendan Gallagher
parent 5ef5fb5617
commit 59fc325310
2 changed files with 4 additions and 2 deletions

View file

@ -263,7 +263,7 @@
contentType : "application/x-www-form-urlencoded", // we must claim this mimetype or CGI will not decode the URL encoding
dataType : "json",
data : {
"quote" : JSON.stringify(oTable.fnGetData()),
"quote" : encodeURI ( JSON.stringify(oTable.fnGetData()) ),
"action" : "add",
},
success : function(){

View file

@ -22,6 +22,7 @@ use warnings;
use CGI qw ( -utf8 );
use JSON;
use URI::Escape;
use autouse 'Data::Dumper' => qw(Dumper);
use C4::Auth;
@ -40,8 +41,9 @@ unless ($status eq "ok") {
}
my $success = 'true';
my $quotes_tmp = uri_unescape( $cgi->param('quote' ) );
my $quotes = decode_json( $quotes_tmp );
my $quotes = decode_json($cgi->param('quote'));
my $action = $cgi->param('action');
my $sth = $dbh->prepare('INSERT INTO quotes (source, text) VALUES (?, ?);');