[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:42:02 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=f81b688
The following commit has been merged in the master branch:
commit f81b688e4b4c10e436def09c6f14e364351277fb
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Sat Oct 30 06:06:15 2010 +0000
Modified test for XMP files to not recognize any XML file with a regular header as XMP.
---
src/xmpsidecar.cpp | 52 +++++++++++++++++++++++++++++++++++-----------------
src/xmpsidecar.hpp | 4 ----
2 files changed, 35 insertions(+), 21 deletions(-)
diff --git a/src/xmpsidecar.cpp b/src/xmpsidecar.cpp
index 16a3c54..72820a1 100644
--- a/src/xmpsidecar.cpp
+++ b/src/xmpsidecar.cpp
@@ -51,11 +51,14 @@ EXIV2_RCSID("@(#) $Id$")
#include <cassert>
// *****************************************************************************
+namespace {
+ const char* xmlHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
";
+ const long xmlHdrCnt = 39; // without the trailing 0-character
+}
+
// class member definitions
namespace Exiv2 {
- const char* XmpSidecar::xmlHeader_ = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
";
- const long XmpSidecar::xmlHdrCnt_ = 39; // without the trailing 0-character
XmpSidecar::XmpSidecar(BasicIo::AutoPtr io, bool create)
: Image(ImageType::xmp, mdXmp, io)
@@ -63,7 +66,7 @@ namespace Exiv2 {
if (create) {
if (io_->open() == 0) {
IoCloser closer(*io_);
- io_->write(reinterpret_cast<const byte*>(xmlHeader_), xmlHdrCnt_);
+ io_->write(reinterpret_cast<const byte*>(xmlHeader), xmlHdrCnt);
}
}
} // XmpSidecar::XmpSidecar
@@ -132,7 +135,7 @@ namespace Exiv2 {
}
if (xmpPacket_.size() > 0) {
if (xmpPacket_.substr(0, 5) != "<?xml") {
- xmpPacket_ = xmlHeader_ + xmpPacket_;
+ xmpPacket_ = xmlHeader + xmpPacket_;
}
BasicIo::AutoPtr tempIo(io_->temporary()); // may throw
assert(tempIo.get() != 0);
@@ -160,17 +163,23 @@ namespace Exiv2 {
bool isXmpType(BasicIo& iIo, bool advance)
{
/*
- Make sure the file starts with and (optional) XML declaration,
- followed by an XMP header (<?xpacket ... ?>) or an <x:xmpmeta>
- element. That doesn't cover all cases, since also x:xmpmeta is
- optional, but let's wait and see.
- */
-
- // Todo: Proper implementation
+ Check if the file starts with an optional XML declaration followed by
+ either an XMP header (<?xpacket ... ?>) or an <x:xmpmeta> element.
- const int32_t len = 13;
+ In addition, in order for empty XmpSidecar objects as created by
+ Exiv2 to pass the test, just an XML header is also considered ok.
+ */
+ const int32_t len = 80;
byte buf[len];
- iIo.read(buf, len);
+ iIo.read(buf, xmlHdrCnt + 1);
+ if ( iIo.eof()
+ && 0 == strncmp(reinterpret_cast<const char*>(buf), xmlHeader, xmlHdrCnt)) {
+ return true;
+ }
+ if (iIo.error() || iIo.eof()) {
+ return false;
+ }
+ iIo.read(buf + xmlHdrCnt + 1, len - xmlHdrCnt - 1);
if (iIo.error() || iIo.eof()) {
return false;
}
@@ -180,10 +189,19 @@ namespace Exiv2 {
start = 3;
}
bool rc = false;
- const std::string head(reinterpret_cast<const char*>(buf + start), len - start);
- if ( head.substr(0, 5) == "<?xml"
- || head.substr(0, 9) == "<?xpacket"
- || head.substr(0, 10) == "<x:xmpmeta") {
+ std::string head(reinterpret_cast<const char*>(buf + start), len - start);
+ if (head.substr(0, 5) == "<?xml") {
+ // Forward to the next tag
+ for (unsigned i = 5; i < head.size(); ++i) {
+ if (head[i] == '<') {
+ head = head.substr(i);
+ break;
+ }
+ }
+ }
+ if ( head.size() > 9
+ && ( head.substr(0, 9) == "<?xpacket"
+ || head.substr(0, 10) == "<x:xmpmeta")) {
rc = true;
}
if (!advance || !rc) {
diff --git a/src/xmpsidecar.hpp b/src/xmpsidecar.hpp
index 71513b4..261c17c 100644
--- a/src/xmpsidecar.hpp
+++ b/src/xmpsidecar.hpp
@@ -98,10 +98,6 @@ namespace Exiv2 {
XmpSidecar& operator=(const XmpSidecar& rhs);
//@}
- // DATA
- static const char* xmlHeader_;
- static const long xmlHdrCnt_;
-
}; // class XmpSidecar
// *****************************************************************************
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list