Skip to content

cleanPgn strips annotations from pgn files #11

@MPolleke

Description

@MPolleke

Hello, thank you for these libraries :)

When I load a pgn file the annotations like '$1' get stripped from the data. This does not happen when the pgn is being set in code.

$parser = new PgnParser( '/annotated.pgn', false );
$gamelist_unparsed = $parser->getUnparsedGames(); // array
var_dump( $gamelist_unparsed );

From the annotated.pgn in the /test/pgn/ directory this will strip the annotations.
Setting the same pgn data in code with setPgnContent() will not strip it.
I can see that distinction in the getUnparsedGames() function, it will call the cleanPgn() function if it is a file.

In the cleanPgn() function, when I comment out this line it works again:
$c = preg_replace("/\\$[0-9]+/s", "", $c);
There might be a reason that this regex is done, I just don't know why :)

By the way, I also don't understand this line in PgnParser->sanitize() since my upload path simply starts with that "/". Am I misunderstanding something?
if (substr($filePath, 0, 1) === "/") return null;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions