Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use file names containing braces as input. #417

Open
1 task done
ivan-asdf opened this issue Mar 16, 2024 · 0 comments
Open
1 task done

Cannot use file names containing braces as input. #417

ivan-asdf opened this issue Mar 16, 2024 · 0 comments
Labels

Comments

@ivan-asdf
Copy link

ivan-asdf commented Mar 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Operating system

NixOS 24.05.20240131.b8b232a (Uakari) x86_64

Installation method

Package Manager (from OS)

Betterlockscreen & Dependency-Versions

Betterlockscreen: version: v4.2.0 (dunst: true, feh: true)
i3lock-color: version 2.13.c.5 © 2010 Michael Stapelberg, © 2015 Cassandra Fox, © 2021 Raymond Li
Version: ImageMagick 7.1.1-27 Q16-HDRI x86_64 9c64c662f:20240120 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fontconfig freetype heic jng jp2 jpeg jxl lcms lqr lzma openexr pangocairo png raw rsvg tiff webp x xml zlib zstd
Compiler: gcc (13.2)
dunst version: 1.9.2
feh version 
Compile-time switches: curl exif inotify verscmp xinerama 
[B] Betterlockscreen

Bug description

If given file name which contains braces - An "eval" fails in the betterlockscreen-wrapped with syntax error upon encountering the brace.

If the file name is a string with escaped braces(workaround attempt) - Then other part of betterlockscreen-wrapped fail which seems to expect a non-escaped string.

Steps to reproduce

  1. Run betterlockscreen -u k\(232\).jpg --fx blur or any other file name which contains braces
    Expect .betterlockscreen-wrapped: eval: line 467: syntax error near unexpected token (`
    The problem is in this eval:
base_resize() {
    local input="$1"
    local output="$2"
    local size="$3"

    echof act "Resizing base image..."
    convert "$input" \
        -resize "$size""^" \
        -gravity center \
        -extent "$size" \
        "$output"
}

(Workaround attempt)

  1. w="k\(232\).jpg"
  2. betterlockscreen -u $w --fx blur
    Expect invalid path: k\(232\).jpg
    The problem seems to be in this more general earlier code which expects normal non-escaped string.
    local path="$1"

    # we have a file
    if [ -f "$path" ]; then
        WALL_LIST+=("$path")
        return
    # we have a directory
    elif [ -d "$path" ]; then
        dir=("$path"/*)
        rdir="${dir[RANDOM % ${#dir[@]}]}"
        get_image "$rdir" # <-- calls itself
    # not file or directory, bail out
    else
        echof err "invalid path: $path"
        exit 1
    fi

}

Relevant log output

betterlockscreen -u k\(232\).jpg --fx blur
[B] Betterlockscreen
[*] Updating image cache...
[=] Detected 1 display(s) @ 2560x1440 total resolution
[=] Original image(s): k(232).jpg
[=] Processing display: DP-4 (1)
[=] Resolution: 2560x1440
[*] Resizing base image...
/nix/store/yqv00z6djnbwzb4gvrdqirmgvyfw6fga-betterlockscreen-4.2.0/bin/.betterlockscreen-wrapped: eval: line 467: syntax error near unexpected token `('
/nix/store/yqv00z6djnbwzb4gvrdqirmgvyfw6fga-betterlockscreen-4.2.0/bin/.betterlockscreen-wrapped: eval: line 467: `convert k(232).jpg -resize 2560x1440^ -gravity center -extent 2560x1440 /home/ivan/.cache/betterlockscreen/1-DP-4/resize.png'
[*] Rendering 'blur' effect...
convert: unable to open image '/home/ivan/.cache/betterlockscreen/1-DP-4/resize.png': No such file or directory @ error/blob.c/OpenBlob/3571.
convert: no images defined `/home/ivan/.cache/betterlockscreen/1-DP-4/blur.png' @ error/convert.c/ConvertImageCommand/3362.
[*] Rendering final wallpaper images...
[*] Rendering final lockscreen images...
[+] Done

w="k\(232\).jpg"
betterlockscreen -u $w --fx blur
[B] Betterlockscreen
[*] Updating image cache...
[=] Detected 1 display(s) @ 2560x1440 total resolution
 invalid path: k\(232\).jpg
@ivan-asdf ivan-asdf added the bug label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant