Compare commits

..

2 Commits

Author SHA1 Message Date
Adam Gastineau
5302d6ea0e fix(mobile): allow URL validation to pass when scheme is not provided 2026-07-22 12:39:23 -07:00
Pavel Miniutka
564cda5088 chore(mobile): Adds Belarusian language option in settings on mobile (#29939)
chore(mobile): add missing Belarusian (be) language option in settings
2026-07-22 17:53:21 +00:00
6 changed files with 60 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ const Map<String, Locale> locales = {
// Additional locales
'Arabic (ar)': Locale('ar'),
'Basque (eu)': Locale('eu'),
'Belarusian (be)': Locale('be'),
'Bosnian (bl)': Locale('bn'),
'Brazilian Portuguese (pt_BR)': Locale('pt', 'BR'),
'Bulgarian (bg)': Locale('bg'),

View File

@@ -10,6 +10,24 @@ String sanitizeUrl(String url) {
return urlWithSchema.trimRight().replaceFirst(RegExp(r"/+$"), "");
}
/// Validates a user-entered server URL
bool isValidServerUrl(String? url) {
if (url == null || url.isEmpty) {
return true;
}
if (!url.contains('://')) {
// Prepend conforming scheme for URL validation
// Uri.tryParse will not parse out host without a scheme provided, even though we assume http(s) when connecting
url = 'http://$url';
}
final parsedUrl = Uri.tryParse(url);
return parsedUrl != null &&
(parsedUrl.scheme.isEmpty || parsedUrl.scheme.startsWith(RegExp(r'https?'))) &&
parsedUrl.host.isNotEmpty;
}
String? getServerUrl() {
final serverUrl = punycodeDecodeUrl(Store.tryGet(StoreKey.serverEndpoint));
final serverUri = serverUrl != null ? Uri.tryParse(serverUrl) : null;

View File

@@ -43,18 +43,7 @@ class LoginForm extends HookConsumerWidget {
final log = Logger('LoginForm');
String? _validateUrl(String? url) {
if (url == null || url.isEmpty) {
return null;
}
final parsedUrl = Uri.tryParse(url);
if (parsedUrl == null || !parsedUrl.isAbsolute || !parsedUrl.scheme.startsWith("http") || parsedUrl.host.isEmpty) {
return 'login_form_err_invalid_url'.tr();
}
return null;
}
String? _validateUrl(String? url) => isValidServerUrl(url) ? null : 'login_form_err_invalid_url'.tr();
String? _validateEmail(String? email) {
if (email == null || email == '') {

View File

@@ -1,9 +1,9 @@
[tools]
"aqua:flutter/flutter" = "3.44.7"
java = "21.0.11+10.0.LTS"
"aqua:flutter/flutter" = "3.44.6"
java = "21.0.2"
[tools."github:CQLabs/homebrew-dcm"]
version = "1.38.2"
version = "1.37.0"
bin = "dcm"
postinstall = "chmod +x \"$MISE_TOOL_INSTALL_PATH/dcm\" || true"

View File

@@ -58,7 +58,7 @@ dependencies:
path_provider: ^2.1.5
path_provider_foundation: ^2.6.0
permission_handler: ^11.4.0
photo_manager: 3.10.0
photo_manager: 3.9.0
pinput: ^5.0.2
punycode: ^1.0.0
scroll_date_picker: ^3.8.0
@@ -68,10 +68,10 @@ dependencies:
sliver_tools: ^0.2.12
stream_transform: ^2.1.1
sqlite3: ^3.3.2
sqlite_async: 0.14.3
sqlite_async: 0.14.2
sqlite3_connection_pool: ^0.2.6
thumbhash: 0.1.0+1
timezone: ^0.11.0
timezone: ^0.9.4
url_launcher: ^6.3.2
uuid: ^4.5.3
wakelock_plus: ^1.3.3

View File

@@ -77,6 +77,40 @@ void main() {
});
});
group('isValidServerUrl', () {
test('should treat null as valid', () {
expect(isValidServerUrl(null), isTrue);
});
test('should treat empty string as valid', () {
expect(isValidServerUrl(''), isTrue);
});
test('should accept a bare host', () {
expect(isValidServerUrl('demo.immich.app'), isTrue);
});
test('should accept a bare host with a port', () {
expect(isValidServerUrl('192.168.1.1:2283'), isTrue);
});
test('should accept an http URL', () {
expect(isValidServerUrl('http://demo.immich.app'), isTrue);
});
test('should accept an https URL', () {
expect(isValidServerUrl('https://demo.immich.app:2283/api'), isTrue);
});
test('should reject a non-http scheme', () {
expect(isValidServerUrl('ftp://demo.immich.app'), isFalse);
});
test('should reject scheme only input', () {
expect(isValidServerUrl('https://'), isFalse);
});
});
group('punycodeDecodeUrl', () {
test('should return null for null input', () {
expect(punycodeDecodeUrl(null), isNull);