Skip to content

Commit

Permalink
read_config_paths: Don't validate entry IDs
Browse files Browse the repository at this point in the history
Not strictly up-to spec, but also won't break anything
An invalid ID should never have an alias set, as `find_entry_paths` prunes them

I feel like this sort of user error isn't worth maintaining code to check for, as the config line plain not working feels obvious enough
It's also easier to comprehend when reading
  • Loading branch information
fluvf committed Dec 17, 2023
1 parent b7f7682 commit dfc44b1
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions xdg-terminal-exec
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,7 @@ read_config_paths() {
# Let `read` trim leading/trailing whitespace from the IDs
while IFS=":$OIFS" read -r entry_id action_id; do
case $entry_id in
# Ignore comments
'#'*) ;;
# Catch directives first

# cache control
# Directives to toggle cache
/enable_cache)
debug "directive $entry_id ${XTE_CACHE_ENABLED+'(ignored)'}"
CACHE_ENABLED=${XTE_CACHE_ENABLED-true}
Expand All @@ -202,20 +198,8 @@ read_config_paths() {
debug "directive $entry_id ${XTE_CACHE_ENABLED+'(ignored)'}"
CACHE_ENABLED=${XTE_CACHE_ENABLED-false}
;;

# `[The extensionless entry filename] should be a valid D-Bus well-known name.`
# `a sequence of non-empty elements separated by dots (U+002E FULL STOP),
# none of which starts with a digit, and each of which contains only characters from the set [a-zA-Z0-9-_]`
# Stricter parts seem to be related only to reversed DNS notation but not common naming
# i.e. there is `2048-qt.desktop`.
# I do not know of any terminal that starts with a number, but it's valid.

# Catch and error on invalid entry ID
*[![:alnum:]_.-]*'.desktop' | '.desktop' | '')
error "Discarded invalid, possibly misspelled, entry ID '$entry_id'"
;;
# Catch valid entry ID
[[:alnum:]_]*'.desktop')
# Catch entry ID
[!#]*'.desktop')
READ_ENTRY_IDS=${READ_ENTRY_IDS:+${READ_ENTRY_IDS}${N}}$entry_id:$action_id
debug "$entry_id : $action_id"
;;
Expand Down

0 comments on commit dfc44b1

Please sign in to comment.