Bug: ASCII PLY parsing fails on files with \r line endings due to binary mode

Open
#45 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start at PLYData(filename) and trace the ASCII parser used when the binary flag is false. Reproduce the failure with an ASCII PLY containing standalone \r blank lines, then verify that equivalent files using \n, \r\n, and \r parse successfully without treating blank lines as data.

Written by the indexing model from the issue text.

Description

When loading an ASCII PLY file via PLYData(filename), the parser fails to properly handle empty lines containing standalone \r (Carriage Return) characters. This occurs because the file is opened in binary mode (preserving raw \r), but the ASCII parser does not explicitly skip them. As a result, lines with \r are treated as valid content, leading to crashes.

Expected behavior:
The parser should safely ignore empty lines regardless of line ending type (\n, \r\n, or \r).

Reproduction:

  • Create an ASCII PLY file with empty lines between header and data.
  • Load it with happly::PLYData plyIn("file.ply", false);
  • Parsing will fail when reading element data.

fily.ply:
ply
format ascii 1.0
element vertex 1
property float x
property float y
property float z
end_header

0.0 0.0 0.0

Dominant language
C++
Stars
406
Forks
74
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nmwsharp/happly

All issues in nmwsharp/happly

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.