Skip to content

Commit

Permalink
Fix string parsing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
phpdave11 committed Jun 14, 2019
1 parent 3dd612d commit b037631
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,14 @@ func (this *PdfReader) readValue(r *bufio.Reader, t string) (*PdfValue, error) {
// This is a string

openBrackets := 1
var s string

// Create new buffer
var buf bytes.Buffer

// Read bytes until brackets are balanced
for openBrackets > 0 {
b, err := r.ReadByte()

if err != nil {
return nil, errors.Wrap(err, "Failed to read byte")
}
Expand All @@ -332,17 +335,19 @@ func (this *PdfReader) readValue(r *bufio.Reader, t string) (*PdfValue, error) {
return nil, errors.Wrap(err, "Failed to read byte")
}

s += string(b) + string(nb)
buf.WriteByte(b)
buf.WriteByte(nb)

continue
}

if openBrackets > 0 {
s += string(b)
buf.WriteByte(b)
}
}

result.Type = PDF_TYPE_STRING
result.String = s
result.String = buf.String()

case "stream":
return nil, errors.New("Stream not implemented")
Expand Down

0 comments on commit b037631

Please sign in to comment.