From 33cf1e21c78d79f96c6ad6a215e1cdce9dc3f8bc Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Mon, 21 Apr 2014 11:57:42 +0300 Subject: [PATCH] [libwspcodec] Added wsp_header_iter_is_content_type() Also, made wsp_header_iter_is_multipart() check stricter. (actually check that it's one of application/vnd.wap.multipart content types) --- Makefile | 2 +- README | 2 +- debian/changelog | 7 +++++++ rpm/libwspcodec.spec | 4 ++-- wspcodec/wsputil.c | 18 ++++++++++++++++-- wspcodec/wsputil.h | 2 ++ 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 323e63f..497b5f6 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ all: debug release pkgconfig # VERSION_MAJOR = 2 -VERSION_MINOR = 1 +VERSION_MINOR = 2 VERSION_RELEASE = 0 VERSION = $(VERSION_MAJOR).$(VERSION_MINOR) diff --git a/README b/README index d05d13e..92b0ba8 100644 --- a/README +++ b/README @@ -1,2 +1,2 @@ Copyright (C) 2010-2011 Intel Corporation. All rights reserved. -Copyright (C) 2013 Jolla Ltd. +Copyright (C) 2013-2014 Jolla Ltd. diff --git a/debian/changelog b/debian/changelog index 2473daf..2d07a43 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +libwspcodec (2.2.0) unstable; urgency=low + + * Added wsp_header_iter_is_content_type() + * Made wsp_header_iter_is_multipart() check stricter + + -- Slava Monich Mon, 21 Apr 2014 01:04:25 +0300 + libwspcodec (2.1.0) unstable; urgency=low * Took out wsp_text_header_iter stuff. diff --git a/rpm/libwspcodec.spec b/rpm/libwspcodec.spec index b387a70..7c81407 100644 --- a/rpm/libwspcodec.spec +++ b/rpm/libwspcodec.spec @@ -1,5 +1,5 @@ Name: libwspcodec -Version: 2.1 +Version: 2.2 Release: 0 Summary: WSP encoder and decoder library Group: Development/Libraries @@ -42,7 +42,7 @@ make install-dev DESTDIR=%{buildroot} %files devel %defattr(-,root,root,-) -%{_libdir}/%{name}-2.1.so +%{_libdir}/%{name}-2.2.so %{_libdir}/pkgconfig/libwspcodec.pc %{_includedir}/libwspcodec/wspcodec/wsputil.h %{_includedir}/libwspcodec/wspcodec/wspcodec.h diff --git a/wspcodec/wsputil.c b/wspcodec/wsputil.c index 0cc2e5a..3fc1dee 100644 --- a/wspcodec/wsputil.c +++ b/wspcodec/wsputil.c @@ -3,6 +3,7 @@ * Multimedia Messaging Service * * Copyright (C) 2010-2011 Intel Corporation. All rights reserved. + * Copyright (C) 2013-2014 Jolla Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -739,11 +740,24 @@ gboolean wsp_header_iter_at_end(struct wsp_header_iter *iter) return FALSE; } +gboolean wsp_header_iter_is_content_type(struct wsp_header_iter *iter) +{ + return iter->max > iter->pos && + is_content_type_header(iter->pdu + iter->pos, iter); +} + gboolean wsp_header_iter_is_multipart(struct wsp_header_iter *iter) { - const unsigned char *pdu = iter->pdu + iter->pos; + const void *value; + + if (!wsp_header_iter_is_content_type(iter)) + return FALSE; + + if (!wsp_decode_content_type(iter->pdu + iter->pos + 1, + iter->max - iter->pos - 1, &value, NULL, NULL)) + return FALSE; - return is_content_type_header(pdu, iter); + return strstr(value, "application/vnd.wap.multipart.") == value; } enum wsp_header_type wsp_header_iter_get_hdr_type(struct wsp_header_iter *iter) diff --git a/wspcodec/wsputil.h b/wspcodec/wsputil.h index f098361..37523e9 100644 --- a/wspcodec/wsputil.h +++ b/wspcodec/wsputil.h @@ -3,6 +3,7 @@ * Multimedia Messaging Service * * Copyright (C) 2010-2011 Intel Corporation. All rights reserved. + * Copyright (C) 2013-2014 Jolla Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -172,6 +173,7 @@ gboolean wsp_header_iter_next(struct wsp_header_iter *iter); unsigned char wsp_header_iter_get_code_page(struct wsp_header_iter *iter); gboolean wsp_header_iter_at_end(struct wsp_header_iter *iter); +gboolean wsp_header_iter_is_content_type(struct wsp_header_iter *iter); gboolean wsp_header_iter_is_multipart(struct wsp_header_iter *iter); enum wsp_header_type wsp_header_iter_get_hdr_type(struct wsp_header_iter *iter);