[ 
https://issues.apache.org/jira/browse/TIKA-4944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18125148#comment-18125148
 ] 

ASF GitHub Bot commented on TIKA-4944:
--------------------------------------

henry-lindeman-glean commented on code in PR #3278:
URL: https://github.com/apache/tika/pull/3278#discussion_r4221618344


##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/onenote/OneNoteTreeWalker.java:
##########
@@ -615,6 +624,20 @@ private Map<String, Object> 
processPropertyValue(PropertyValue propertyValue,
                         // have the onlyLatestRevision = false
                         handleRichEditTextUnicode(content.size());
                     }
+                } else if (propertyValue.propertyId.propertyEnum ==
+                        OneNotePropertyEnum.NotebookManagementEntityGuid
+                        && content.size() == 16) {
+                    ByteBuffer guidBuffer = ByteBuffer.allocate(16);
+                    dif.read(guidBuffer);
+                    String guid = 
pooledGuid(GUID.fromMicrosoftBytes(guidBuffer.array()).toString());
+                    propMap.put("notebookManagementEntityGuid", guid);
+                    // Version-history copies of a page are object-space 
roots; only the
+                    // current page's metadata is referenced via 
MetaDataObjectsAboveGraphSpace.
+                    if (objectType != OneNoteJcid.PAGE_METADATA || 
(parentPropertyId != null
+                            && parentPropertyId.propertyEnum ==
+                            
OneNotePropertyEnum.MetaDataObjectsAboveGraphSpace)) {
+                        addClassicEntityGuid(objectType, guid);
+                    }

Review Comment:
   Partial read in OneNoteTreeWalker (claimed High) — false positive.
   Copilot says dif.read(guidBuffer) isn't guaranteed to fill the 16-byte 
buffer and the NPE risk if decode returns null. But dif is a 
OneNoteDirectFileResource, whose read(ByteBuffer) loops until the buffer is 
drained and explicitly throws IOException("End of stream reached earlier than 
expected") on premature EOF. A silent short read is impossible. The NPE claim 
is also impossible: guidBuffer.array() is always exactly 16 bytes, and 
GUID.fromMicrosoftBytes only returns null for wrong-length input.





> Emit onenote page guids in properties
> -------------------------------------
>
>                 Key: TIKA-4944
>                 URL: https://issues.apache.org/jira/browse/TIKA-4944
>             Project: Tika
>          Issue Type: Improvement
>          Components: parser
>            Reporter: Henry Lindeman
>            Priority: Minor
>
> Onenote section files contain page GUIDs which can be used to reconstruct a 
> url pointing to a page in the MS SaaS Onenote application. Since MS hands you 
> the documents section at a time the only other way to get to the page GUID is 
> to ask MS to list the pages in the section, which we'd prefer not to do



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to