fix: harden printer selection and setup
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled

This commit is contained in:
Admin 2026-09-24 00:00:53 +00:00
parent d4975836b9
commit 50f043ca9c
2 changed files with 9 additions and 5 deletions

View File

@ -69,7 +69,7 @@ pub fn install_virtual_printer(target_printer: &str) -> Result<VirtualPrinterSta
if target_printer.is_empty() {
return Err(anyhow!("choose the physical printer to forward to first"));
}
if target_printer.eq_ignore_ascii_case(VIRTUAL_PRINTER_NAME) {
if is_virtual_printer_name(target_printer) {
return Err(anyhow!("FieldLens Print cannot forward to itself"));
}
@ -237,7 +237,7 @@ if (Get-PrinterPort -Name $portName -ErrorAction SilentlyContinue) {{
#[cfg(target_os = "windows")]
fn ps_quote(value: &str) -> String {
value.replace(''', "''")
value.replace('\'', "''")
}
#[cfg(target_os = "linux")]

View File

@ -69,7 +69,7 @@ let config: AppConfig
let jobs: Job[] = []
let status: Status
let loginTimer: number | undefined
let currentVersion = '0.1.1'
let currentVersion = '0.1.2'
let bundleType: BundleType | null = null
let availableUpdate: Update | null = null
let updateBusy = false
@ -218,7 +218,7 @@ function writeForm(next: AppConfig) {
function renderPrinters() {
const select = el<HTMLSelectElement>('forwardPrinter')
const current = config?.forwardPrinter || select.value
const current = select.value || config?.forwardPrinter || ''
const options = systemPrinters.filter((printer) => !printer.isVirtual)
select.innerHTML = '<option value="">Choose a printer…</option>' + options.map((printer) => {
@ -291,7 +291,11 @@ async function refreshStatus() {
el('forwardPrinter').addEventListener('change', () => {
const selected = systemPrinters.find((printer) => printer.name === el<HTMLSelectElement>('forwardPrinter').value)
if (selected?.address) el<HTMLInputElement>('forwardAddr').value = selected.address
if (selected?.address) {
el<HTMLInputElement>('forwardAddr').value = selected.address
} else if (selected) {
el<HTMLInputElement>('forwardAddr').value = ''
}
renderPrinters()
})