cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with UTF-8 strings/content sending by POST

louise
Champ in-the-making
Champ in-the-making
Alfresco version: (Community Network): Current version 2.9.0 (B 683) schema 116

I've a big problem - just below - while trying to store content after editing on custom editor, and sending by HTTP POST into a custom webscript. Looks like the webservice always recoding UTF-8 characters to UTF-8.

As a difference between community edition 2.1 and 2.9B; this 'bug?' presents in 2.1 in GET and POST, but only in POST on version 2.9B…

Is there a workaround to fix this issue, or i need to wait for next Alfresco release?

Shell script to test answering on service:

#!/bin/sh

PROTOCOL="http"
USERPASS="admin:admin"
HOST="127.0.0.1:8080"

# get
htdump "${PROTOCOL}://${USERPASS}@${HOST}/alfresco/service/eu/tenderworks/formtest?formdata=ékezetesókősségík"

# post
htdump -post="formdata=ékezetesókősségík" "${PROTOCOL}://${USERPASS}@${HOST}/alfresco/service/eu/tenderworks/formtest"


Answer by GET:

<pre>
ékezetesókősségík
</pre>

Answer by POST:

<pre>
ékezetesókősségík
</pre>
8 REPLIES 8

louise
Champ in-the-making
Champ in-the-making
Fixed by a base64 encoder/decoder (encode content before POST, and decode in webscript): http://www.webtoolkit.info/javascript-base64.html

louise
Champ in-the-making
Champ in-the-making
Same effect with 3.0 Labs too… Smiley Sad

ev1lgenius
Champ in-the-making
Champ in-the-making
Hello LouiSe,

I have exactlly the same problem and as you I'm using base64 encoding. But when script decodes message and saves it to the file message becomes corrupted like "ékezetesókÅ‘sségÃk". So could you pls write a sample web script, where content is decoded from base64 string?

Thank you.

louise
Champ in-the-making
Champ in-the-making
Example part of my webscript:


for each (field in formdata.fields) {
  if(field.name == 'parent') {
    var parent = field.value;
  } else if (field.name == 'updatenoderef') {
    var updatenoderef = field.value;
  } else if (field.name == 'file' && field.isFile) {
    var filename = field.filename;
    var content = field.content;
  }
}

var contentData = Base64.decode(content);

var newContent = parentNode.childByNamePath(name);
if (newContent == null && parentNode.hasPermission("CreateChildren")) {
  newContent = parentNode.createFile(name);
}
           
newContent.properties.content.write(contentData);
newContent.properties.content.encoding = "UTF-8";

if (args.title != undefined) {
  newContent.properties.title = Utf8.decode(args.title);
}
           
if (args.description != undefined) {
  newContent.properties.description = Utf8.decode(args.description);
}
           
newContent.save();

ev1lgenius
Champ in-the-making
Champ in-the-making
Thanks for the sample script, but it seems that write method and encoding property is not supported in version 2.2, so instead of
newContent.properties.content.write(contentData);
newContent.properties.content.encoding = "UTF-8";
I just wrote
newContent.properties.content.content = contentData
, but it didn't help  :x

Moreover if I just skip the encoding/decoding procedure and write content directly, like newContent.properties.content.content = "ékezetesókősségík", behaviour will be the same.

louise
Champ in-the-making
Champ in-the-making
Just follow this thread: http://forums.alfresco.com/en/viewtopic.php?f=14&t=10286

db.url=jdbc:mysql://localhost/alfresco?useUnicode=true&characterEncoding=utf-8

ev1lgenius
Champ in-the-making
Champ in-the-making
It doesn't help either.

louise
Champ in-the-making
Champ in-the-making
Sorry, i haven't other idea Smiley Sad