mirror of
https://github.com/immich-app/immich.git
synced 2026-07-23 13:54:05 +03:00
Compare commits
2 Commits
renovate/m
...
fix/auto-h
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5302d6ea0e | ||
|
|
564cda5088 |
@@ -6,6 +6,7 @@ const Map<String, Locale> locales = {
|
|||||||
// Additional locales
|
// Additional locales
|
||||||
'Arabic (ar)': Locale('ar'),
|
'Arabic (ar)': Locale('ar'),
|
||||||
'Basque (eu)': Locale('eu'),
|
'Basque (eu)': Locale('eu'),
|
||||||
|
'Belarusian (be)': Locale('be'),
|
||||||
'Bosnian (bl)': Locale('bn'),
|
'Bosnian (bl)': Locale('bn'),
|
||||||
'Brazilian Portuguese (pt_BR)': Locale('pt', 'BR'),
|
'Brazilian Portuguese (pt_BR)': Locale('pt', 'BR'),
|
||||||
'Bulgarian (bg)': Locale('bg'),
|
'Bulgarian (bg)': Locale('bg'),
|
||||||
|
|||||||
@@ -10,6 +10,24 @@ String sanitizeUrl(String url) {
|
|||||||
return urlWithSchema.trimRight().replaceFirst(RegExp(r"/+$"), "");
|
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() {
|
String? getServerUrl() {
|
||||||
final serverUrl = punycodeDecodeUrl(Store.tryGet(StoreKey.serverEndpoint));
|
final serverUrl = punycodeDecodeUrl(Store.tryGet(StoreKey.serverEndpoint));
|
||||||
final serverUri = serverUrl != null ? Uri.tryParse(serverUrl) : null;
|
final serverUri = serverUrl != null ? Uri.tryParse(serverUrl) : null;
|
||||||
|
|||||||
@@ -43,18 +43,7 @@ class LoginForm extends HookConsumerWidget {
|
|||||||
|
|
||||||
final log = Logger('LoginForm');
|
final log = Logger('LoginForm');
|
||||||
|
|
||||||
String? _validateUrl(String? url) {
|
String? _validateUrl(String? url) => isValidServerUrl(url) ? null : 'login_form_err_invalid_url'.tr();
|
||||||
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? _validateEmail(String? email) {
|
String? _validateEmail(String? email) {
|
||||||
if (email == null || email == '') {
|
if (email == null || email == '') {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[tools]
|
[tools]
|
||||||
"aqua:flutter/flutter" = "3.44.7"
|
"aqua:flutter/flutter" = "3.44.6"
|
||||||
java = "21.0.11+10.0.LTS"
|
java = "21.0.2"
|
||||||
|
|
||||||
[tools."github:CQLabs/homebrew-dcm"]
|
[tools."github:CQLabs/homebrew-dcm"]
|
||||||
version = "1.38.2"
|
version = "1.37.0"
|
||||||
bin = "dcm"
|
bin = "dcm"
|
||||||
postinstall = "chmod +x \"$MISE_TOOL_INSTALL_PATH/dcm\" || true"
|
postinstall = "chmod +x \"$MISE_TOOL_INSTALL_PATH/dcm\" || true"
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ dependencies:
|
|||||||
path_provider: ^2.1.5
|
path_provider: ^2.1.5
|
||||||
path_provider_foundation: ^2.6.0
|
path_provider_foundation: ^2.6.0
|
||||||
permission_handler: ^11.4.0
|
permission_handler: ^11.4.0
|
||||||
photo_manager: 3.10.0
|
photo_manager: 3.9.0
|
||||||
pinput: ^5.0.2
|
pinput: ^5.0.2
|
||||||
punycode: ^1.0.0
|
punycode: ^1.0.0
|
||||||
scroll_date_picker: ^3.8.0
|
scroll_date_picker: ^3.8.0
|
||||||
@@ -68,10 +68,10 @@ dependencies:
|
|||||||
sliver_tools: ^0.2.12
|
sliver_tools: ^0.2.12
|
||||||
stream_transform: ^2.1.1
|
stream_transform: ^2.1.1
|
||||||
sqlite3: ^3.3.2
|
sqlite3: ^3.3.2
|
||||||
sqlite_async: 0.14.3
|
sqlite_async: 0.14.2
|
||||||
sqlite3_connection_pool: ^0.2.6
|
sqlite3_connection_pool: ^0.2.6
|
||||||
thumbhash: 0.1.0+1
|
thumbhash: 0.1.0+1
|
||||||
timezone: ^0.11.0
|
timezone: ^0.9.4
|
||||||
url_launcher: ^6.3.2
|
url_launcher: ^6.3.2
|
||||||
uuid: ^4.5.3
|
uuid: ^4.5.3
|
||||||
wakelock_plus: ^1.3.3
|
wakelock_plus: ^1.3.3
|
||||||
|
|||||||
@@ -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', () {
|
group('punycodeDecodeUrl', () {
|
||||||
test('should return null for null input', () {
|
test('should return null for null input', () {
|
||||||
expect(punycodeDecodeUrl(null), isNull);
|
expect(punycodeDecodeUrl(null), isNull);
|
||||||
|
|||||||
Reference in New Issue
Block a user