https://bugs.kde.org/show_bug.cgi?id=528370

            Bug ID: 528370
           Summary: KSaneCore mangles non-ASCII SANE device names by
                    calling sane_open() with toLatin1() .
    Classification: Applications
           Product: Skanpage
      Version First 26.08.2
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

## KSaneCore mangles non-ASCII SANE device names by calling `sane_open()` with
`toLatin1()`

SANE device names are read as UTF-8, but KSaneCore converts them to Latin-1
before `sane_open()`. Any non-ASCII name (for example Chinese) becomes
`????`, and opening the device fails with `SANE_STATUS_INVALID`.
Skanpage shows “Failed to open selected device.”

## Environment

- libksane / KSaneCore: 26.08.2
- Skanpage: 26.08.2
- OS: Arch Linux, kernel 7.3.0-2-cachyos-bore-lto
- Qt: 6.12.0
- Backend: sane-airscan 0.99.38, eSCL
- Device name: airscan:e0:物理组打印机1.

### Steps to reproduce

1. Configure a SANE device whose name contains non-ASCII characters. For
example, add a manual eSCL device in airscan.conf:
```conf
[devices]
"物理组打印机1" = http://192.168.1.14:8080/eSCL/
```

2. Confirm that SANE itself can see and use the device:
```bash
scanimage -L
scanimage -d 'airscan:e0:物理组打印机1' --format=png -o /tmp/test.png
Both commands work; this shows the device name and backend are valid.
```

3. Open Skanpage and select `airscan:e0:物理组打印机1`.

### Actual

The device is listed, but opening it fails.

### My Fix

Use toUtf8() at both call sites:

```diff
- status = sane_open(deviceName.toLatin1().constData(), &d->m_saneHandle);
+ status = sane_open(deviceName.toUtf8().constData(), &d->m_saneHandle);
```

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to