https://issues.apache.org/bugzilla/show_bug.cgi?id=47498

           Summary: HyperlinkRecord truncates URLs
           Product: POI
           Version: 3.5-dev
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Created an attachment (id=23942)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23942)
diff -r -u poi-3.5-beta6 poi-edit

Hi,

While testing POI's hyperlink functionality, I noticed that URL Hyperlinks are
parsed incorrectly at the Record level. They are truncated by 11 characters
from the right (12 characters if we count the null termination).
Reproducibility: 100%


FIX:
A quick look at HyperlinkRecord reveals the problem:

in 
public HyperlinkRecord(RecordInputStream)
[...]
if ((_linkOpts & HLINK_TARGET_FRAME) != 0) { 
  int nChars = fieldSize/2;
  _address = in.readUnicodeLEString(nChars);
} else {
  int nChars = (fieldSize - TAIL_SIZE)/2;
  _address = in.readUnicodeLEString(nChars);
  _uninterpretedTail = readTail(URL_TAIL, in);
}
[...]


Should be (as far as my understanding goes):

if ((_linkOpts & HLINK_TARGET_FRAME) == 0) {
  int nChars = fieldSize/2;
  _address = in.readUnicodeLEString(nChars);
} else {
  int nChars = (fieldSize - TAIL_SIZE)/2;
  _address = in.readUnicodeLEString(nChars);
  _uninterpretedTail = readTail(URL_TAIL, in);
}


I've attached a patch against 3.5-beta6.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to