On Do, 2011-07-21 at 12:21 +0200, Patrick Ohly wrote:
> Now there is only one other problem with PHOTO uris. They get encoded as
> binary data:
>
> PHOTO;VALUE=uri:http://example.com/photo.jpg
> =>
> PHOTO;ENCODING=B;VALUE=uri:aHR0cDovL2V4YW1wbGUuY29tL3Bob3RvLmpwZw==
>
> Is that because PHOTO is defined as "blob"?
>
> Would it make sense to be selective in the encoder for "blob" and only
> use binary encoding if the content contains non-printable characters?
This patch has the desired effect:
index 4105d03..616cb68 100644
--- a/src/sysync/mimedirprofile.cpp
+++ b/src/sysync/mimedirprofile.cpp
@@ -23,6 +23,7 @@
#include "syncagent.h"
+#include <ctype.h>
using namespace sysync;
@@ -2274,9 +2275,17 @@ sInt16 TMimeDirProfileHandler::generateValue(
}
// append to existing string
fldP->appendToString(outval,maxSiz);
- // force B64 encoding
- aEncoding=enc_base64;
- aNonASCII=false;
+ // force B64 encoding if non-printable or non-ASCII characters
+ // are in the value
+ size_t len = outval.size();
+ for (size_t i = 0; i < len; i++) {
+ char c = outval[i];
+ if (!isascii(c) || !isprint(c)) {
+ aEncoding=enc_base64;
+ aNonASCII=false;
+ break;
+ }
+ }
}
else {
// apply custom field(s)-to-string translation if needed
I tried it with both binary PHOTO and VALUE=uri.
--
Best Regards, Patrick Ohly
The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.
_______________________________________________
os-libsynthesis mailing list
[email protected]
http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis