<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Attribute::getName() returns wrong value for /N when UTF-16BE is used"
href="https://bugs.freedesktop.org/show_bug.cgi?id=84722">84722</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Attribute::getName() returns wrong value for /N when UTF-16BE is used
</td>
</tr>
<tr>
<th>Product</th>
<td>poppler
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>general
</td>
</tr>
<tr>
<th>Assignee</th>
<td>poppler-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>luigi.scarso@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>In the following pdf object
/N has value 'elementname' encoded as UTF-16BE
19 0 obj
<< /K 18 0 R /S /div /Type /StructElem /A
<< /P [ <<
/N <feff0065006c0065006d0065006e0074006e0061006d0065>
/V <feff004100410041> >> ] /O /UserProperties >> /Pg 15 0 R /P 17 0 R >>
endobj
Attribute::getName() returns 0xfe 0xff 0x00..0x65 but the caller doesn't know
the size, so it uses only 0xfe 0xff 0x00.
I propose these patches:
1) another constructor Attribute(const char *nameA, Object *valueA, int lenA)
2) a new method GooString *getUserPropertyName() to keep backwards
compatibility (getName() is in the public interface)
3) a patch to parseUserProperty
--- 0.26.4/poppler/StructElement.cc 2014-09-11 18:28:21.000000000 +0200
+++ p0.26.4/poppler/StructElement.cc 2014-10-06 09:13:31.013375479 +0200
@@ -690,6 +690,23 @@
valueA->copy(&value);
}
+Attribute::Attribute(const char *nameA, Object *valueA, int lenA):
+ type(UserProperty),
+ owner(UserProperties),
+ revision(0),
+ name(nameA,lenA),
+ value(),
+ hidden(gFalse),
+ formatted(NULL)
+{
+ assert(valueA);
+ valueA->copy(&value);
+}
+
+
+
+
+
Attribute::Attribute(Type type, Object *valueA):
type(type),
owner(UserProperties), // TODO: Determine corresponding owner from Type
@@ -785,13 +802,17 @@
return entry ? entry->type : Unknown;
}
+
Attribute *Attribute::parseUserProperty(Dict *property)
{
Object obj, value;
const char *name = NULL;
+ int len = 0 ;
- if (property->lookup("N", &obj)->isString())
+ if (property->lookup("N", &obj)->isString()){
name = obj.getString()->getCString();
+ len = obj.getString()->getLength();
+ }
else if (obj.isName())
name = obj.getName();
else {
@@ -807,7 +828,7 @@
return NULL;
}
- Attribute *attribute = new Attribute(name, &value);
+ Attribute *attribute = new Attribute(name, &value,len) ;
value.free();
obj.free();
--- 0.26.4/poppler/StructElement.h 2014-09-11 18:28:20.000000000 +0200
+++ p0.26.4/poppler/StructElement.h 2014-10-06 09:13:53.469376410 +0200
@@ -76,6 +76,9 @@
// Creates an UserProperty attribute, with an arbitrary name and value.
Attribute(const char *name, Object *value);
+ // Creates an UserProperty attribute, with an arbitrary name of lenght len
and value.
+ Attribute(const char *name, Object *value, int len);
+
GBool isOk() const { return type != Unknown; }
// Name, type and value can be set only on construction.
@@ -87,6 +90,9 @@
static Object *getDefaultValue(Type type);
const char *getName() const { return type == UserProperty ?
name.getCString() : getTypeName(); }
+ GooString *getUserPropertyName() const { return type == UserProperty ?
name.copy() : NULL; }
+
+
// The revision is optional, and defaults to zero.
Guint getRevision() const { return revision; }</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>