diff --git a/app/src/main/java/io/xpipe/app/action/XPipeUrlProvider.java b/app/src/main/java/io/xpipe/app/action/XPipeUrlProvider.java index c21b8fb11..30f267fe3 100644 --- a/app/src/main/java/io/xpipe/app/action/XPipeUrlProvider.java +++ b/app/src/main/java/io/xpipe/app/action/XPipeUrlProvider.java @@ -1,5 +1,6 @@ package io.xpipe.app.action; +import io.xpipe.app.core.AppCache; import io.xpipe.app.core.AppRestart; import io.xpipe.app.core.window.AppDialog; import io.xpipe.app.ext.ProcModuleProvider; @@ -26,12 +27,20 @@ public class XPipeUrlProvider implements LauncherUrlProvider { } if ("action".equals(a)) { + if (!checkPermission()) { + return null; + } + var query = uri.getQuery(); var action = ActionUrls.parse(query); return action.orElse(null); } if ("sync".equals(a)) { + if (!checkPermission()) { + return null; + } + var repo = new String(Base64Helper.fromBase64UrlString(uri.getPath()), StandardCharsets.UTF_8); var alreadySynced = AppPrefs.get().storageGitRemote().getValue() != null; if (alreadySynced && !repo.equals(AppPrefs.get().storageGitRemote().getValue())) { @@ -47,4 +56,17 @@ public class XPipeUrlProvider implements LauncherUrlProvider { return null; } + + private boolean checkPermission() { + var cache = AppCache.getBoolean("externalUrlsPermitted", false); + if (cache) { + return true; + } + + var r = AppDialog.confirm("externalUrl"); + if (r) { + AppCache.update("externalUrlsPermitted", true); + } + return r; + } } diff --git a/app/src/main/java/io/xpipe/app/core/AppInstance.java b/app/src/main/java/io/xpipe/app/core/AppInstance.java index aef4fed32..1b9703261 100644 --- a/app/src/main/java/io/xpipe/app/core/AppInstance.java +++ b/app/src/main/java/io/xpipe/app/core/AppInstance.java @@ -84,7 +84,8 @@ public class AppInstance { client.get() .performRequest(DaemonOpenExchange.Request.builder() .arguments(inputs) - .directory(AppProperties.get().getDataDir()) + // Don't change dir when opening inputs + .directory(inputs.isEmpty() ? AppProperties.get().getDataDir() : null) .build()); } } catch (Exception ex) { @@ -115,7 +116,6 @@ public class AppInstance { client.get() .performRequest(DaemonOpenExchange.Request.builder() .arguments(List.of(e.getURI().toString())) - .directory(AppProperties.get().getDataDir()) .build()); } catch (Exception ex) { ErrorEventFactory.fromThrowable(ex).expected().omit().handle(); diff --git a/app/src/main/java/io/xpipe/app/core/AppOpenArguments.java b/app/src/main/java/io/xpipe/app/core/AppOpenArguments.java index fa9dea45e..c36098864 100644 --- a/app/src/main/java/io/xpipe/app/core/AppOpenArguments.java +++ b/app/src/main/java/io/xpipe/app/core/AppOpenArguments.java @@ -97,7 +97,7 @@ public class AppOpenArguments { try { var path = Path.of(input); - if (Files.isRegularFile(path)) { + if (Files.isRegularFile(path) && path.isAbsolute() && path.getParent() != null) { path = path.getParent(); } diff --git a/app/src/main/java/io/xpipe/app/secret/SecretManager.java b/app/src/main/java/io/xpipe/app/secret/SecretManager.java index fcab32ff4..63502a076 100644 --- a/app/src/main/java/io/xpipe/app/secret/SecretManager.java +++ b/app/src/main/java/io/xpipe/app/secret/SecretManager.java @@ -5,14 +5,23 @@ import io.xpipe.app.process.CountDown; import io.xpipe.app.process.SecretReference; import io.xpipe.app.util.GlobalTimer; import io.xpipe.app.util.SecretValue; +import lombok.Value; import java.time.Duration; +import java.time.Instant; import java.util.*; import java.util.stream.Collectors; public class SecretManager { - private static final Map secrets = new HashMap<>(); + @Value + private static class CachedValue { + + SecretValue value; + Instant expiry; + } + + private static final Map secrets = new HashMap<>(); private static final Set progress = new HashSet<>(); public static synchronized Optional getProgress(UUID requestId, UUID storeId) { @@ -119,7 +128,7 @@ public class SecretManager { .collect(Collectors.toSet()); secrets.entrySet().removeAll(oldSecrets); - for (Map.Entry e : oldSecrets) { + for (Map.Entry e : oldSecrets) { var newRef = new SecretReference(newId, e.getKey().getSubId()); secrets.put(newRef, e.getValue()); } @@ -130,19 +139,16 @@ public class SecretManager { } public static synchronized void cache(SecretReference ref, SecretValue value, Duration duration) { - secrets.put(ref, value); - if (duration != null && duration.isPositive()) { - GlobalTimer.delay( - () -> { - synchronized (SecretManager.class) { - secrets.remove(ref); - } - }, - duration); - } + secrets.put(ref, new CachedValue(value, duration != null && duration.isPositive() ? Instant.now().plus(duration) : null)); } public static synchronized Optional get(SecretReference ref) { - return Optional.ofNullable(secrets.get(ref)); + var found = secrets.get(ref); + if (found.getExpiry() != null && found.getExpiry().isAfter(Instant.now())) { + secrets.remove(ref); + return Optional.empty(); + } + + return Optional.of(found.getValue()); } } diff --git a/app/src/main/java/io/xpipe/app/util/ContextualFileReference.java b/app/src/main/java/io/xpipe/app/util/ContextualFileReference.java index 8c1df8755..b4b2e3cbe 100644 --- a/app/src/main/java/io/xpipe/app/util/ContextualFileReference.java +++ b/app/src/main/java/io/xpipe/app/util/ContextualFileReference.java @@ -78,8 +78,13 @@ public class ContextualFileReference { public String serialize() { var start = getDataDir(); + var startString = start.toString(); var normalizedPath = FilePath.of(path).normalize().toUnix(); - if (normalizedPath.startsWith(start) && !normalizedPath.equals(start)) { + var normalizedString = normalizedPath.toString(); + // This guarantees a case-insensitive check + var startsWith = normalizedString.length() > startString.length() && normalizedString + .substring(0, startString.length()).equalsIgnoreCase(startString); + if (startsWith) { return "" + "/" + normalizedPath.relativize(start); } return path; diff --git a/dist/jpackage.gradle b/dist/jpackage.gradle index 6c66d4ecc..c5b208e97 100644 --- a/dist/jpackage.gradle +++ b/dist/jpackage.gradle @@ -42,7 +42,7 @@ jlink { // '--strip-debug', '--no-header-files', '--no-man-pages', - '--compress', '0', + '--compress', 'zip-0', '--ignore-signing-information' ] diff --git a/lang/strings/translations_da.properties b/lang/strings/translations_da.properties index 97be9eeea..c9e98b411 100644 --- a/lang/strings/translations_da.properties +++ b/lang/strings/translations_da.properties @@ -1341,6 +1341,8 @@ vaultUserLegacy=Vault-bruger (begrænset kompatibilitetstilstand med ældre vers upgradeInstructions=Opgraderingsvejledning externalActionTitle=Anmodning om ekstern handling externalActionContent=Der er anmodet om en ekstern handling. Vil du tillade, at der udføres handlinger uden for XPipe? +externalUrlTitle=Anmodning om handling via ekstern URL +externalUrlContent=Der blev åbnet en ekstern URL-handling. Vil du tillade, at der fremover kan åbnes URL'er uden for XPipe? noScriptStateAvailable=Opdater for at fastslå scriptkompatibilitet ... documentationDescription=Se dokumentationen customEditorCommandInTerminal=Kør en brugerdefineret kommando i en terminal diff --git a/lang/strings/translations_de.properties b/lang/strings/translations_de.properties index 3c347c5bc..9ee984432 100644 --- a/lang/strings/translations_de.properties +++ b/lang/strings/translations_de.properties @@ -1334,6 +1334,8 @@ vaultUserLegacy=Vault-Benutzer (eingeschränkter Kompatibilitätsmodus für ält upgradeInstructions=Anweisungen zum Upgrade externalActionTitle=Anforderung einer externen Aktion externalActionContent=Eine externe Aktion wurde angefordert. Möchtest du zulassen, dass Aktionen von außerhalb von XPipe gestartet werden? +externalUrlTitle=Anfrage für eine externe URL-Aktion +externalUrlContent=Eine externe URL-Aktion wurde geöffnet. Möchtest du in Zukunft das Öffnen von URLs von außerhalb von XPipe zulassen? noScriptStateAvailable=Aktualisiere die Seite, um die Skriptkompatibilität zu prüfen ... documentationDescription=Schau dir die Dokumentation an customEditorCommandInTerminal=Benutzerdefinierten Befehl in einem Terminal ausführen diff --git a/lang/strings/translations_en.properties b/lang/strings/translations_en.properties index d931a4e94..d16edb6dd 100644 --- a/lang/strings/translations_en.properties +++ b/lang/strings/translations_en.properties @@ -1368,6 +1368,8 @@ vaultUserLegacy=Vault user (Limited legacy compatibility mode) upgradeInstructions=Upgrade instructions externalActionTitle=External action request externalActionContent=An external action was requested. Do you want to allow launching actions from outside XPipe? +externalUrlTitle=External URL action request +externalUrlContent=An external URL action was opened. Do you want to allow launching URLs from outside XPipe? noScriptStateAvailable=Refresh to determine script compatibility ... documentationDescription=Check out the documentation customEditorCommandInTerminal=Run custom command in a terminal diff --git a/lang/strings/translations_es.properties b/lang/strings/translations_es.properties index 589e658c3..a0f0288f8 100644 --- a/lang/strings/translations_es.properties +++ b/lang/strings/translations_es.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Usuario de Vault (modo de compatibilidad heredada limitada) upgradeInstructions=Instrucciones de actualización externalActionTitle=Solicitud de acción externa externalActionContent=Se ha solicitado una acción externa. ¿Quieres permitir que se inicien acciones desde fuera de XPipe? +externalUrlTitle=Solicitud de acción de URL externa +externalUrlContent=Se ha abierto una acción de URL externa. ¿Quieres permitir que se abran URL desde fuera de XPipe en el futuro? noScriptStateAvailable=Actualiza la página para comprobar la compatibilidad del script... documentationDescription=Echa un vistazo a la documentación customEditorCommandInTerminal=Ejecutar un comando personalizado en un terminal diff --git a/lang/strings/translations_fr.properties b/lang/strings/translations_fr.properties index 6e61e3b61..e1f7d2e24 100644 --- a/lang/strings/translations_fr.properties +++ b/lang/strings/translations_fr.properties @@ -1337,6 +1337,8 @@ vaultUserLegacy=Utilisateur du coffre-fort (mode de compatibilité héritée lim upgradeInstructions=Instructions de mise à jour externalActionTitle=Demande d'action externe externalActionContent=Une action externe a été demandée. Tu veux autoriser le lancement d'actions depuis l'extérieur de XPipe ? +externalUrlTitle=Demande d'action vers une URL externe +externalUrlContent=Une action URL externe a été ouverte. Tu veux autoriser le lancement d'URL depuis l'extérieur de XPipe à l'avenir ? noScriptStateAvailable=Actualise la page pour vérifier la compatibilité du script... documentationDescription=Consulte la documentation customEditorCommandInTerminal=Exécuter une commande personnalisée dans un terminal diff --git a/lang/strings/translations_id.properties b/lang/strings/translations_id.properties index da8425f5c..2dfc2419f 100644 --- a/lang/strings/translations_id.properties +++ b/lang/strings/translations_id.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Pengguna Vault (Mode kompatibilitas warisan terbatas) upgradeInstructions=Petunjuk pembaruan externalActionTitle=Permintaan tindakan eksternal externalActionContent=Telah diminta tindakan eksternal. Apakah Anda ingin mengizinkan peluncuran tindakan dari luar XPipe? +externalUrlTitle=Permintaan tindakan URL eksternal +externalUrlContent=Tindakan URL eksternal telah dibuka. Apakah Anda ingin mengizinkan peluncuran URL dari luar XPipe di masa mendatang? noScriptStateAvailable=Segarkan untuk menentukan kompatibilitas skrip ... documentationDescription=Silakan lihat dokumentasinya customEditorCommandInTerminal=Menjalankan perintah khusus di terminal diff --git a/lang/strings/translations_it.properties b/lang/strings/translations_it.properties index d019df8bf..9e41f9110 100644 --- a/lang/strings/translations_it.properties +++ b/lang/strings/translations_it.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Utente di Vault (modalità di compatibilità legacy limitata) upgradeInstructions=Istruzioni per l'aggiornamento externalActionTitle=Richiesta di azione esterna externalActionContent=È stata richiesta un'azione esterna. Vuoi consentire l'avvio di azioni dall'esterno di XPipe? +externalUrlTitle=Richiesta di azione URL esterno +externalUrlContent=È stata aperta un'azione URL esterna. Vuoi consentire in futuro l'apertura di URL dall'esterno di XPipe? noScriptStateAvailable=Aggiorna per verificare la compatibilità dello script... documentationDescription=Dai un'occhiata alla documentazione customEditorCommandInTerminal=Esegui un comando personalizzato in un terminale diff --git a/lang/strings/translations_ja.properties b/lang/strings/translations_ja.properties index 4d6863abb..64c1efcd4 100644 --- a/lang/strings/translations_ja.properties +++ b/lang/strings/translations_ja.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Vaultユーザー(限定的なレガシー互換モード) upgradeInstructions=アップグレードの手順 externalActionTitle=外部アクションのリクエスト externalActionContent=外部からのアクションが要求された。XPipeの外部からのアクションの実行を許可するか? +externalUrlTitle=外部URLアクションのリクエスト +externalUrlContent=外部URLアクションが開かれた。今後、XPipeの外部からURLを起動することを許可するか? noScriptStateAvailable=スクリプトの互換性を確認するためにページを更新する…… documentationDescription=ドキュメントを確認する customEditorCommandInTerminal=ターミナルでカスタムコマンドを実行する diff --git a/lang/strings/translations_ko.properties b/lang/strings/translations_ko.properties index 26d700560..39e85f8d0 100644 --- a/lang/strings/translations_ko.properties +++ b/lang/strings/translations_ko.properties @@ -1335,6 +1335,8 @@ vaultUserLegacy=Vault 사용자 (레거시 호환성 모드 제한) upgradeInstructions=업그레이드 방법 externalActionTitle=외부 작업 요청 externalActionContent=외부 작업이 요청되었습니다. XPipe 외부에서 작업을 실행하도록 허용하시겠습니까? +externalUrlTitle=외부 URL 동작 요청 +externalUrlContent=외부 URL 작업이 열렸습니다. 향후 XPipe 외부에서 URL을 실행하는 것을 허용하시겠습니까? #custom noScriptStateAvailable=스크립트 호환성을 확인하려면 새로고침 ... documentationDescription=문서를 확인해 보세요 diff --git a/lang/strings/translations_nl.properties b/lang/strings/translations_nl.properties index b3ab11606..40691156c 100644 --- a/lang/strings/translations_nl.properties +++ b/lang/strings/translations_nl.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Vault-gebruiker (Beperkte compatibiliteitsmodus voor oudere vers upgradeInstructions=Upgrade-instructies externalActionTitle=Verzoek om externe actie externalActionContent=Er is een externe actie aangevraagd. Wil je toestaan dat er acties worden gestart van buiten XPipe? +externalUrlTitle=Verzoek tot uitvoering van een externe URL-actie +externalUrlContent=Er is een externe URL-actie geopend. Wil je in de toekomst toestaan dat er URL's van buiten XPipe worden geopend? noScriptStateAvailable=Ververs de pagina om te kijken of het script compatibel is ... documentationDescription=Bekijk de documentatie customEditorCommandInTerminal=Een aangepast commando uitvoeren in een terminal diff --git a/lang/strings/translations_pl.properties b/lang/strings/translations_pl.properties index 430c67935..7b74d033e 100644 --- a/lang/strings/translations_pl.properties +++ b/lang/strings/translations_pl.properties @@ -1304,6 +1304,8 @@ vaultUserLegacy=Użytkownik Vault (tryb ograniczonej kompatybilności z starszym upgradeInstructions=Instrukcje aktualizacji externalActionTitle=Żądanie akcji zewnętrznej externalActionContent=Zgłoszono żądanie wykonania akcji zewnętrznej. Czy chcesz zezwolić na uruchamianie akcji spoza XPipe? +externalUrlTitle=Żądanie akcji dotyczące zewnętrznego adresu URL +externalUrlContent=Została otwarta akcja z zewnętrznym adresem URL. Czy chcesz zezwolić na otwieranie adresów URL spoza XPipe w przyszłości? noScriptStateAvailable=Odśwież stronę, żeby sprawdzić zgodność skryptu... documentationDescription=Zajrzyj do dokumentacji customEditorCommandInTerminal=Uruchom niestandardowe polecenie w terminalu diff --git a/lang/strings/translations_pt.properties b/lang/strings/translations_pt.properties index 8f43699c2..6c7e4013c 100644 --- a/lang/strings/translations_pt.properties +++ b/lang/strings/translations_pt.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Utilizador do Vault (modo de compatibilidade com versões antiga upgradeInstructions=Instruções de atualização externalActionTitle=Pedido de ação externa externalActionContent=Foi solicitada uma ação externa. Queres permitir que sejam iniciadas ações a partir do exterior do XPipe? +externalUrlTitle=Pedido de ação de URL externo +externalUrlContent=Foi aberta uma ação de URL externa. Queres permitir que se abram URLs a partir do exterior do XPipe no futuro? noScriptStateAvailable=Atualiza para verificar a compatibilidade do script... documentationDescription=Dá uma olhadela na documentação customEditorCommandInTerminal=Executar um comando personalizado num terminal diff --git a/lang/strings/translations_ru.properties b/lang/strings/translations_ru.properties index 661968fc1..f4c7ac4ba 100644 --- a/lang/strings/translations_ru.properties +++ b/lang/strings/translations_ru.properties @@ -1395,6 +1395,8 @@ vaultUserLegacy=Пользователь хранилища (режим огра upgradeInstructions=Инструкции по обновлению externalActionTitle=Запрос на внешнее действие externalActionContent=Поступил запрос на выполнение внешнего действия. Хочешь разрешить запуск действий из-за пределов XPipe? +externalUrlTitle=Запрос на действие с внешним URL-адресом +externalUrlContent=Было запущено действие с внешним URL-адресом. Хочешь разрешить запуск URL-адресов извне XPipe в будущем? noScriptStateAvailable=Обнови страницу, чтобы проверить совместимость скриптов... documentationDescription=Загляни в документацию customEditorCommandInTerminal=Запустить пользовательскую команду в терминале diff --git a/lang/strings/translations_sv.properties b/lang/strings/translations_sv.properties index ca0609382..b7d74668d 100644 --- a/lang/strings/translations_sv.properties +++ b/lang/strings/translations_sv.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Vault-användare (begränsat kompatibilitetsläge för äldre ve upgradeInstructions=Uppgraderingsanvisningar externalActionTitle=Begäran om extern åtgärd externalActionContent=En extern åtgärd har begärts. Vill du tillåta att åtgärder startas från utanför XPipe? +externalUrlTitle=Begäran om åtgärd via extern URL +externalUrlContent=En extern URL-åtgärd har öppnats. Vill du tillåta att URL:er från utanför XPipe öppnas i framtiden? noScriptStateAvailable=Uppdatera för att kontrollera skriptkompatibiliteten ... documentationDescription=Läs dokumentationen customEditorCommandInTerminal=Kör ett anpassat kommando i en terminal diff --git a/lang/strings/translations_tr.properties b/lang/strings/translations_tr.properties index 75eb86aa8..095ff6da7 100644 --- a/lang/strings/translations_tr.properties +++ b/lang/strings/translations_tr.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Vault kullanıcısı (Sınırlı eski sürüm uyumluluk modu) upgradeInstructions=Yükseltme talimatları externalActionTitle=Harici eylem isteği externalActionContent=Harici bir eylem talep edildi. XPipe dışından eylemlerin başlatılmasına izin vermek istiyor musunuz? +externalUrlTitle=Harici URL eylem isteği +externalUrlContent=Harici bir URL eylemi açıldı. Gelecekte XPipe dışından URL'lerin açılmasına izin vermek istiyor musunuz? noScriptStateAvailable=Komut dosyası uyumluluğunu belirlemek için sayfayı yenileyin ... documentationDescription=Belgelere göz atın customEditorCommandInTerminal=Terminalde özel komut çalıştırma diff --git a/lang/strings/translations_vi.properties b/lang/strings/translations_vi.properties index c938c5b65..50956636c 100644 --- a/lang/strings/translations_vi.properties +++ b/lang/strings/translations_vi.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Người dùng Vault (Chế độ tương thích cũ giới hạ upgradeInstructions=Hướng dẫn nâng cấp externalActionTitle=Yêu cầu thực hiện hành động bên ngoài externalActionContent=Có yêu cầu thực hiện một hành động từ bên ngoài. Cậu có muốn cho phép khởi chạy các hành động từ bên ngoài XPipe không? +externalUrlTitle=Yêu cầu hành động URL bên ngoài +externalUrlContent=Một hành động URL bên ngoài đã được mở. Cậu có muốn cho phép mở các URL từ bên ngoài XPipe trong tương lai không? noScriptStateAvailable=Làm mới để kiểm tra tính tương thích của tập lệnh ... documentationDescription=Cậu hãy xem tài liệu hướng dẫn nhé customEditorCommandInTerminal=Chạy lệnh tùy chỉnh trong terminal diff --git a/lang/strings/translations_zh-Hans.properties b/lang/strings/translations_zh-Hans.properties index a87c10236..ee75f0986 100644 --- a/lang/strings/translations_zh-Hans.properties +++ b/lang/strings/translations_zh-Hans.properties @@ -1753,6 +1753,8 @@ upgradeInstructions=升级说明 externalActionTitle=外部操作请求 #custom externalActionContent=检测到一个外部操作请求。是否允许从 XPipe 外部启动操作? +externalUrlTitle=外部URL操作请求 +externalUrlContent=已打开一个外部 URL 操作。您是否允许今后从 XPipe 外部启动 URL? #custom noScriptStateAvailable=刷新以检测脚本兼容性… documentationDescription=请查阅文档 diff --git a/lang/strings/translations_zh-Hant.properties b/lang/strings/translations_zh-Hant.properties index 1d7d9d9cb..a68d37b4f 100644 --- a/lang/strings/translations_zh-Hant.properties +++ b/lang/strings/translations_zh-Hant.properties @@ -1303,6 +1303,8 @@ vaultUserLegacy=Vault 使用者(有限的舊版相容模式) upgradeInstructions=升級說明 externalActionTitle=外部動作請求 externalActionContent=系統收到外部動作請求。您是否允許從 XPipe 外部啟動動作? +externalUrlTitle=外部 URL 動作請求 +externalUrlContent=已開啟一個外部 URL 動作。您是否要允許今後從 XPipe 外部啟動 URL? noScriptStateAvailable=請重新整理以確認腳本相容性…… documentationDescription=請參閱相關文件 customEditorCommandInTerminal=在終端機中執行自訂指令