Skip to content

Commit

Permalink
Added stricter FEN validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenBadger committed May 7, 2015
1 parent 1eebd4e commit 95843b1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def move(request):
return JsonResponse({"status": "error",
"error_desc": "Position missing in request."})
try:
chess.Board(fen=position)
temp_board = chess.Board(fen=position)
if temp_board.status() != chess.STATUS_VALID:
raise ValueError("Invalid FEN.")
except ValueError:
return JsonResponse({"status": "error",
"error_desc": "Invalid position in request."})
Expand Down

0 comments on commit 95843b1

Please sign in to comment.