Skip to content

Commit

Permalink
decode PGN from URL - closes #16286
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 6, 2024
1 parent ae2b345 commit b6350c4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/UserAnalysis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ final class UserAnalysis(
def pgn(pgn: String) = Open:
val pov = makePov(none, Standard)
val orientation = get("color").flatMap(Color.fromName) | pov.color
val decodedPgn =
lila.common.String
.decodeUriPath(pgn.take(5000))
.map(_.replace("_", " ").replace("+", " ").trim)
.filter(_.nonEmpty)
Ok.async:
env.api.roundApi
.userAnalysisJson(pov, ctx.pref, none, orientation, owner = false)
.map: data =>
views.board.userAnalysis(data, pov, inlinePgn = pgn.replace("_", " ").some)
views.board.userAnalysis(data, pov, inlinePgn = decodedPgn)
.map(_.enforceCrossSiteIsolation)

private[controllers] def makePov(fen: Option[Fen.Full], variant: Variant): Pov =
Expand Down

0 comments on commit b6350c4

Please sign in to comment.