Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH obexd] Fix breaking long lines in vCard's fields
@ 2011-10-14 14:01 Rafal Michalski
  2011-10-14 18:40 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Rafal Michalski @ 2011-10-14 14:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Rafal Michalski

Previously limit length for vCard's (vCard 2.1 with Quoted Printable
encoding) property line was always set as 75 (QP_LINE_LEN), after
processing each single subfield (for instance under ADR property).
Thus it was not possible to reach limit equal to 0 (then breaking line
is required) for all property subfields.
This patch fixes that issue and length of first line, containing property
parameters, is limited as well.
---
 plugins/vcard.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/plugins/vcard.c b/plugins/vcard.c
index 743f19f..7cc7994 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -277,6 +277,8 @@ static gboolean utf8_select(const char *field)
 static void vcard_qp_print_encoded(GString *vcards, const char *desc, ...)
 {
 	const char *field, *charset = "";
+	const char *encoding = ";ENCODING=QUOTED-PRINTABLE";
+	size_t limit, param_len;
 	va_list ap;
 
 	va_start(ap, desc);
@@ -290,13 +292,16 @@ static void vcard_qp_print_encoded(GString *vcards, const char *desc, ...)
 
 	va_end(ap);
 
-	vcard_printf(vcards, "%s;ENCODING=QUOTED-PRINTABLE%s:", desc, charset);
+	vcard_printf(vcards, "%s%s%s:", desc, encoding, charset);
 	g_string_truncate(vcards, vcards->len - 2);
 
+	param_len = strlen(desc) + strlen(encoding) + strlen(charset) + 1;
+	limit = QP_LINE_LEN - param_len;
+
 	va_start(ap, desc);
 
 	for (field = va_arg(ap, char *); field != NULL; ) {
-		size_t i, limit = QP_LINE_LEN, size = strlen(field);
+		size_t i, size = strlen(field);
 
 		for (i = 0; i < size; ++i) {
 			if (set_qp_encoding(field[i])) {
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH obexd] Fix breaking long lines in vCard's fields
  2011-10-14 14:01 [PATCH obexd] Fix breaking long lines in vCard's fields Rafal Michalski
@ 2011-10-14 18:40 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2011-10-14 18:40 UTC (permalink / raw)
  To: Rafal Michalski; +Cc: linux-bluetooth

Hi Rafal,

On Fri, Oct 14, 2011, Rafal Michalski wrote:
> Previously limit length for vCard's (vCard 2.1 with Quoted Printable
> encoding) property line was always set as 75 (QP_LINE_LEN), after
> processing each single subfield (for instance under ADR property).
> Thus it was not possible to reach limit equal to 0 (then breaking line
> is required) for all property subfields.
> This patch fixes that issue and length of first line, containing property
> parameters, is limited as well.
> ---
>  plugins/vcard.c |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-14 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-14 14:01 [PATCH obexd] Fix breaking long lines in vCard's fields Rafal Michalski
2011-10-14 18:40 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox