lichess-org / lichobile

lichess.org mobile application
https://lichess.org/mobile
GNU General Public License v3.0
2.04k stars 318 forks source link

Invalid PGN generated when sharing a game (and Analysis > Import game should bail gracefully on invalid PGN) #348

Closed quinncomendant closed 8 years ago

quinncomendant commented 8 years ago

During an attempt to test lichess crashing (see #347) I tried to import the following PGN into Analysis mode (Tools > Analysis board > … > Import game > Paste the PGN text here). After pasting the PGN and clicking the import button, the button turns to an ⏳ and stays that way forever. The PGN never imports. Tapping outside the dialog closes it, but returning to the import game dialog the textbox is empty but the button still has an unclickable ⏳.

0. Ne3 c6 1. d4 d5 2. c3 e5 3. b4 exd4 4. cxd4 Qxb4 5. a3 Qxd4 6. N3c2 Qf6 7. a4 Bf5 8. Ra3 Ne6 9. Nf3 Bd6 10. Re3 Bc5 11. Re5 Nd6 12. Bg5 Qg6 13. Ne3 f6 14. Bxf5 Qh5 15. Rxe6 fxg5 16. g4 Qf7 17. Nxg5 Nxf5 18. Nxf7 Nxe3 19. Qh3 Kxf7 20. Re5 Nd1 21. Rf5+ Kg8 22. Kg2 Nxf2 23. Qf3 Nxh1 24. Kxh1 Re8 25. Qc3 g6 26. Rg5 Bd6 27. h4 Rxe2 28. h5 Re6 29. hxg6 hxg6+ 30. Kg2 Rh2+ 31. Kg1 Ree2 32. Rxg6+ Kf7 33. Qg7+ Ke8 34. Qg8+ Bf8 35. Re6+ Kd7 36. Qf7+ Be7 37. Qxe7+ Kc8 38. Rxe2 Rh8 39. a5 b6 40. a6 c5 41. Qxa7 Rh6 42. Qb7+ Kd8 43. a7 Rc6 *

This PGN is from a over-the-board game that I emailed directly from lichess to myself.

Unihedro commented 8 years ago

Is there supposed to be a 0.? PGNs I've seen are supposed to start with 1. (move one).

TonyRotella commented 8 years ago

It appears as though the PGN is totally busted. Not only is there a move zero, but I can also find numerous errors blindfolded, e.g. 4...Qxb4, 6.N3c2 Qf6, etc, are all not legal moves.

quinncomendant commented 8 years ago

@Unihedro Then the issue here is different:

  1. The "Share" feature of an over-the-board game is generating invalid PGN (it's worth checking if PGN export from others modes of Lichess is broken too).
  2. Lichess Import game needs better error-recover when encountering invalid PGN.

Here's the full output I received from the share function:

[Event "Casual Game"]
[Site "http://lichess.org"]
[Date "June 10, 2016"]
[White "Anonymous"]
[Black "Anonymous"]
[Result "*"]
[PlyCount "88"]
[FEN "rbbnnqkr/pppppppp/8/8/8/8/PPPPPPPP/RBBNNQKR w KQkq - 0 1"]
[Variant "Chess960"]
[Termination "?"]

0. Ne3 c6 1. d4 d5 2. c3 e5 3. b4 exd4 4. cxd4 Qxb4 5. a3 Qxd4 6. N3c2 Qf6 7. a4 Bf5 8. Ra3 Ne6 9. Nf3 Bd6 10. Re3 Bc5 11. Re5 Nd6 12. Bg5 Qg6 13. Ne3 f6 14. Bxf5 Qh5 15. Rxe6 fxg5 16. g4 Qf7 17. Nxg5 Nxf5 18. Nxf7 Nxe3 19. Qh3 Kxf7 20. Re5 Nd1 21. Rf5+ Kg8 22. Kg2 Nxf2 23. Qf3 Nxh1 24. Kxh1 Re8 25. Qc3 g6 26. Rg5 Bd6 27. h4 Rxe2 28. h5 Re6 29. hxg6 hxg6+ 30. Kg2 Rh2+ 31. Kg1 Ree2 32. Rxg6+ Kf7 33. Qg7+ Ke8 34. Qg8+ Bf8 35. Re6+ Kd7 36. Qf7+ Be7 37. Qxe7+ Kc8 38. Rxe2 Rh8 39. a5 b6 40. a6 c5 41. Qxa7 Rh6 42. Qb7+ Kd8 43. a7 Rc6 *

@TonyRotella Haha, probably because it's a “Chess960” variant. 😏

Thanks for noticing the real problem here, guys. 👌 May I suggest reopening this issue?

Unihedro commented 8 years ago

"Unable to import PGN in analysis mode" <- this is still not true.

veloce commented 8 years ago

So:

Is there anything more to fix?

veloce commented 8 years ago

I updated scalachess to the current master in scalachessjs. Since I don't know what other issue there is, and it might be solved by scalachess update, I'm closing this.