## Description

On Linux/Wayland, the robot uses the XDG Desktop Portal (ScreenCast and 
RemoteDesktop) and stores the `restore_token` returned by `Start` in 
`~/.java/robot/remote-desktop-tokens.properties`. Later sessions send it back, 
so the permission dialog is shown only once.

`validateToken()` in `screencast_portal.c` accepts a token only if 
`g_uuid_string_is_valid()` returns true. The portal documentation only 
specifies `restore_token` as a string (`s`) and does not define its format 
([RemoteDesktop](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.RemoteDesktop.html),
 
[ScreenCast](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.ScreenCast.html)).

Recent xdg-desktop-portal versions (seen with 1.22.1) no longer generate UUIDs. 
Their tokens look like `vjebXVIEGhjtuuqCsiwYoQ`, and the frontend accepts both 
formats (see 
[`xdp_session_persistence_validate_restore_token()`](https://github.com/flatpak/xdg-desktop-portal/blob/1.22.1/src/xdp-session-persistence.c)).

Because the new tokens fail the UUID check, the robot never sends 
`restore_token` in `SelectDevices` / `SelectSources`. Every new robot iteration 
shows the permission dialog again. 

## Steps to reproduce

1. Fedora 44 GNOME (xdg-desktop-portal 1.22.1, xdg-desktop-portal-gnome 50.0), 
Wayland session.
2. Run a system test that uses the robot, e.g. 
`test.robot.javafx.scene.RobotTest`.
3. Approve the "Remote Desktop" dialog with "Allow Remote Interaction" turned 
on.
4. The approval dialog will reappear

**Expected:** the session is restored from the stored token and no dialog is 
shown.
**Actual:** the dialog is shown on every new robot iteration.

## Fix
Do not assume a format for the token: accept any non-empty, valid UTF-8 strie 
it. It still has to be valid UTF-8, since it is passed 
to`g_variant_new_string()`.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

-------------

Commit messages:
 - [Linux] Robot: screencast restore token is wrongly assumed to be a UUID
 - [Linux] Robot: screencast restore token is wrongly assumed to be a UUID

Changes: https://git.openjdk.org/jfx/pull/2356/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=2356&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8396109
  Stats: 6 lines in 1 file changed: 1 ins; 2 del; 3 mod
  Patch: https://git.openjdk.org/jfx/pull/2356.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/2356/head:pull/2356

PR: https://git.openjdk.org/jfx/pull/2356

Reply via email to