diff options
author | Samuel Lidén Borell <samuel@slbdata.se> | 2011-07-12 21:09:37 +0200 |
---|---|---|
committer | Samuel Lidén Borell <samuel@slbdata.se> | 2011-07-12 21:09:37 +0200 |
commit | 0bc3834f3e56bf137b654bb08688a0c1be602204 (patch) | |
tree | c696fc2fbb6efe8b504327d9245bfb858437606b /plugin | |
parent | 4e4e7d495b30c8fbea64bbd306f570eb5f61f473 (diff) | |
download | fribid-0bc3834f3e56bf137b654bb08688a0c1be602204.tar.gz fribid-0bc3834f3e56bf137b654bb08688a0c1be602204.tar.bz2 fribid-0bc3834f3e56bf137b654bb08688a0c1be602204.zip |
Add the TextCharacterEncoding parameter
This parameter is just stored in the signature. It doesn't change how
the message is displayed to the user (this is always autodetected).
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/ipc.c | 1 | ||||
-rw-r--r-- | plugin/plugin.c | 23 | ||||
-rw-r--r-- | plugin/plugin.h | 1 |
3 files changed, 25 insertions, 0 deletions
diff --git a/plugin/ipc.c b/plugin/ipc.c index 07ee51c..81f2135 100644 --- a/plugin/ipc.c +++ b/plugin/ipc.c @@ -160,6 +160,7 @@ int sign_performAction_Sign(Plugin *plugin) { sendHeader(&pipeinfo, plugin, PC_Sign); sendSignCommon(&pipeinfo, plugin); + pipe_sendString(pipeinfo.out, plugin->info.sign.messageEncoding); pipe_sendString(pipeinfo.out, plugin->info.sign.message); pipe_sendOptionalString(pipeinfo.out, plugin->info.sign.invisibleMessage); diff --git a/plugin/plugin.c b/plugin/plugin.c index 6712613..f1dc3a8 100644 --- a/plugin/plugin.c +++ b/plugin/plugin.c @@ -37,6 +37,14 @@ #include "plugin.h" +/** + * Sets parameters that have some other value than "" or 0 as + * their default value. + */ +static void setInitialParamValues(Plugin *plugin) { + plugin->info.sign.messageEncoding = strdup("UTF-8"); +} + Plugin *plugin_new(PluginType pluginType, const char *url, const char *hostname, const char *ip, Window windowId) { @@ -54,6 +62,7 @@ Plugin *plugin_new(PluginType pluginType, const char *url, return NULL; } + setInitialParamValues(plugin); return plugin; } @@ -101,6 +110,7 @@ void plugin_reset(Plugin *plugin) { free(plugin->info.sign.challenge); free(plugin->info.sign.policys); free(plugin->info.sign.subjectFilter); + free(plugin->info.sign.messageEncoding); free(plugin->info.sign.message); free(plugin->info.sign.invisibleMessage); free(plugin->info.sign.signature); @@ -114,6 +124,7 @@ void plugin_reset(Plugin *plugin) { memset(&plugin->info.regutil, 0, sizeof(plugin->info.regutil)); break; } + setInitialParamValues(plugin); } static char **getCommonParamPointer(Plugin *plugin, const char *name) { @@ -130,6 +141,7 @@ static char **getParamPointer(Plugin *plugin, const char *name) { return getCommonParamPointer(plugin, name); case PT_Signer: if (!g_ascii_strcasecmp(name, "Nonce")) return &plugin->info.sign.challenge; + if (!g_ascii_strcasecmp(name, "TextCharacterEncoding")) return &plugin->info.sign.messageEncoding; if (!g_ascii_strcasecmp(name, "TextToBeSigned")) return &plugin->info.sign.message; if (!g_ascii_strcasecmp(name, "NonVisibleData")) return &plugin->info.sign.invisibleMessage; return getCommonParamPointer(plugin, name); @@ -210,6 +222,17 @@ bool sign_setParam(Plugin *plugin, const char *name, const char *value) { return true; } + // TextCharacterEncoding: Only the values "UTF-8" and "ISO-88591-1" + // are allowed (case-sensitive). This value is NOT escaped in the XML + // signature. + if (plugin->type == PT_Signer && + !g_ascii_strcasecmp(name, "TextCharacterEncoding") && + strcmp(value, "UTF-8") && strcmp(value, "ISO-8859-1")) { + // Not sure about the name of this error code... + plugin->lastError = BIDERR_ValueTooLong; + return false; + } + // Handle string parameters char **valuePtr = getParamPointer(plugin, name); diff --git a/plugin/plugin.h b/plugin/plugin.h index a06146f..f529103 100644 --- a/plugin/plugin.h +++ b/plugin/plugin.h @@ -64,6 +64,7 @@ typedef struct { int32_t serverTime; char *policys; char *subjectFilter; + char *messageEncoding; char *message; char *invisibleMessage; /* Output parameters */ |