Address review: trace request size and contact-share translation
- Manual path trace validates the request that will actually be sent (round trips become 2n-1 hops, 3-byte hops go out as 4-byte prefixes) against the 172-byte frame and 64-hop firmware limits, and disables Run with an explanation when it does not fit. PathTraceMapScreen also refuses to send an oversized request. - Contact-share tokens are never passed through message translation, so the share cannot be mangled before sending.
This commit is contained in:
1 parent
c939f7a29c
commit
80ead2fc2d
45 files changed
+210
-2
No files matched your search
@@ -115,3 +115,28 @@ class PathTraceInputParser {
|
||||
static String _stripPrefix(String t) =>
|
||||
(t.startsWith('0x') || t.startsWith('0X')) ? t.substring(2) : t;
|
||||
}
|
||||
|
||||
/// `CMD_SEND_TRACE_PATH` header: command, tag x4, auth x4, flags.
|
||||
const int traceRequestHeaderBytes = 10;
|
||||
|
||||
/// Bytes per hop the trace request uses for [hopWidth]-byte hashes. Trace
|
||||
/// flags encode the width as a power of two, so 3-byte hops are sent as
|
||||
/// 4-byte public-key prefixes.
|
||||
int traceHashWidthFor(int hopWidth) => hopWidth <= 1
|
||||
? 1
|
||||
: hopWidth == 2
|
||||
? 2
|
||||
: 4;
|
||||
|
||||
/// Hops actually sent: a round trip goes out and back over the same hops,
|
||||
/// sharing the far end (n hops become 2n - 1).
|
||||
int tracedHopCount(int hops, {required bool roundTrip}) =>
|
||||
roundTrip && hops > 1 ? hops * 2 - 1 : hops;
|
||||
|
||||
/// Whether [input] traced in this mode fits one request: the firmware takes
|
||||
/// at most [maxPathSize] hops and the frame must stay within [maxFrameSize].
|
||||
bool traceFitsInRequest(PathTraceInput input, {required bool roundTrip}) {
|
||||
final hops = tracedHopCount(input.hops.length, roundTrip: roundTrip);
|
||||
final bytes = hops * traceHashWidthFor(input.hopWidth);
|
||||
return hops <= maxPathSize && traceRequestHeaderBytes + bytes <= maxFrameSize;
|
||||
}
|
||||
@@ -3659,6 +3659,7 @@
|
||||
"manualTrace_errorMixedWidths": "Всички хешове трябва да са с еднаква дължина",
|
||||
"manualTrace_errorUnsupportedWidth": "Хешовете трябва да са 1, 2 или 3 байта (2, 4 или 6 шестнадесетични знаци)",
|
||||
"manualTrace_errorTooManyHops": "Пътят е твърде дълъг (максимум {max} байта)",
|
||||
"manualTrace_errorTraceTooLong": "Твърде много хопове за трасиране в една заявка. Премахнете няколко хопа или изберете „Както е въведено“.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -4272,6 +4272,7 @@
|
||||
"manualTrace_errorMixedWidths": "Všechny hashe musí mít stejnou délku",
|
||||
"manualTrace_errorUnsupportedWidth": "Hashe musí mít 1, 2 nebo 3 bajty (2, 4 nebo 6 hexadecimálních znaků)",
|
||||
"manualTrace_errorTooManyHops": "Cesta je příliš dlouhá (maximum {max} bajtů)",
|
||||
"manualTrace_errorTraceTooLong": "Příliš mnoho skoků pro trasování v jednom požadavku. Odeberte některé skoky nebo zvolte „Dle zadání“.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3794,6 +3794,7 @@
|
||||
"manualTrace_errorMixedWidths": "Alle Hashes müssen die gleiche Länge haben",
|
||||
"manualTrace_errorUnsupportedWidth": "Hashes müssen 1, 2 oder 3 Bytes lang sein (2, 4 oder 6 Hex-Zeichen)",
|
||||
"manualTrace_errorTooManyHops": "Pfad ist zu lang (maximal {max} Bytes)",
|
||||
"manualTrace_errorTraceTooLong": "Zu viele Hops für eine einzelne Verfolgung. Entfernen Sie einige Hops oder wählen Sie „Wie eingegeben“.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -1498,6 +1498,7 @@
|
||||
"manualTrace_errorMixedWidths": "All hashes must be the same length",
|
||||
"manualTrace_errorUnsupportedWidth": "Hashes must be 1, 2 or 3 bytes (2, 4 or 6 hex characters)",
|
||||
"manualTrace_errorTooManyHops": "Path is too long (maximum {max} bytes)",
|
||||
"manualTrace_errorTraceTooLong": "Too many hops to trace in one request. Remove some hops or choose As entered.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3845,6 +3845,7 @@
|
||||
"manualTrace_errorMixedWidths": "Todos los hashes deben tener la misma longitud",
|
||||
"manualTrace_errorUnsupportedWidth": "Los hashes deben ser de 1, 2 o 3 bytes (2, 4 o 6 caracteres hexadecimales)",
|
||||
"manualTrace_errorTooManyHops": "La ruta es demasiado larga (máximo {max} bytes)",
|
||||
"manualTrace_errorTraceTooLong": "Demasiados saltos para trazar en una sola solicitud. Quita algunos saltos o elige «Tal como se introdujo».",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3793,6 +3793,7 @@
|
||||
"manualTrace_errorMixedWidths": "Tous les hachages doivent avoir la même longueur",
|
||||
"manualTrace_errorUnsupportedWidth": "Les hachages doivent faire 1, 2 ou 3 octets (2, 4 ou 6 caractères hexadécimaux)",
|
||||
"manualTrace_errorTooManyHops": "Le chemin est trop long (maximum {max} octets)",
|
||||
"manualTrace_errorTraceTooLong": "Trop de sauts à tracer en une seule requête. Retirez des sauts ou choisissez « Tel que saisi ».",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3750,6 +3750,7 @@
|
||||
"manualTrace_errorMixedWidths": "Minden hashnek azonos hosszúságúnak kell lennie",
|
||||
"manualTrace_errorUnsupportedWidth": "A hasheknek 1, 2 vagy 3 bájtosnak kell lenniük (2, 4 vagy 6 hexadecimális karakter)",
|
||||
"manualTrace_errorTooManyHops": "Az útvonal túl hosszú (legfeljebb {max} bájt)",
|
||||
"manualTrace_errorTraceTooLong": "Túl sok ugrás egyetlen nyomkövetési kéréshez. Távolíts el néhány ugrást, vagy válaszd a „Megadott sorrendben” lehetőséget.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3793,6 +3793,7 @@
|
||||
"manualTrace_errorMixedWidths": "Tutti gli hash devono avere la stessa lunghezza",
|
||||
"manualTrace_errorUnsupportedWidth": "Gli hash devono essere di 1, 2 o 3 byte (2, 4 o 6 caratteri esadecimali)",
|
||||
"manualTrace_errorTooManyHops": "Il percorso è troppo lungo (massimo {max} byte)",
|
||||
"manualTrace_errorTraceTooLong": "Troppi salti da tracciare in una sola richiesta. Rimuovi alcuni salti o scegli «Come inserito».",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3999,6 +3999,7 @@
|
||||
"manualTrace_errorMixedWidths": "すべてのハッシュは同じ長さにしてください",
|
||||
"manualTrace_errorUnsupportedWidth": "ハッシュは1、2、3バイト(16進数で2、4、6文字)にしてください",
|
||||
"manualTrace_errorTooManyHops": "経路が長すぎます(最大 {max} バイト)",
|
||||
"manualTrace_errorTraceTooLong": "1回のリクエストでトレースできるホップ数を超えています。ホップを減らすか、「入力どおり」を選んでください。",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3999,6 +3999,7 @@
|
||||
"manualTrace_errorMixedWidths": "모든 해시의 길이가 같아야 합니다",
|
||||
"manualTrace_errorUnsupportedWidth": "해시는 1, 2 또는 3바이트(16진수 2, 4 또는 6자)여야 합니다",
|
||||
"manualTrace_errorTooManyHops": "경로가 너무 깁니다(최대 {max}바이트)",
|
||||
"manualTrace_errorTraceTooLong": "한 번의 요청으로 추적하기에는 홉이 너무 많습니다. 홉을 줄이거나 “입력한 대로”를 선택하세요.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -5166,6 +5166,12 @@ abstract class AppLocalizations {
|
||||
/// **'Path is too long (maximum {max} bytes)'**
|
||||
String manualTrace_errorTooManyHops(int max);
|
||||
|
||||
/// No description provided for @manualTrace_errorTraceTooLong.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Too many hops to trace in one request. Remove some hops or choose As entered.'**
|
||||
String get manualTrace_errorTraceTooLong;
|
||||
|
||||
/// No description provided for @mapCache_title.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -2924,6 +2924,10 @@ class AppLocalizationsBg extends AppLocalizations {
|
||||
return 'Пътят е твърде дълъг (максимум $max байта)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Твърде много хопове за трасиране в една заявка. Премахнете няколко хопа или изберете „Както е въведено“.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Кеш на офлайн карти';
|
||||
|
||||
|
||||
@@ -2907,6 +2907,10 @@ class AppLocalizationsCs extends AppLocalizations {
|
||||
return 'Cesta je příliš dlouhá (maximum $max bajtů)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Příliš mnoho skoků pro trasování v jednom požadavku. Odeberte některé skoky nebo zvolte „Dle zadání“.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Offline mezipaměť map';
|
||||
|
||||
|
||||
@@ -2924,6 +2924,10 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
return 'Pfad ist zu lang (maximal $max Bytes)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Zu viele Hops für eine einzelne Verfolgung. Entfernen Sie einige Hops oder wählen Sie „Wie eingegeben“.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Offline-Karten-Cache';
|
||||
|
||||
|
||||
@@ -2879,6 +2879,10 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
return 'Path is too long (maximum $max bytes)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Too many hops to trace in one request. Remove some hops or choose As entered.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Offline Map Cache';
|
||||
|
||||
|
||||
@@ -2913,6 +2913,10 @@ class AppLocalizationsEs extends AppLocalizations {
|
||||
return 'La ruta es demasiado larga (máximo $max bytes)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Demasiados saltos para trazar en una sola solicitud. Quita algunos saltos o elige «Tal como se introdujo».';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Caché de mapa sin conexión';
|
||||
|
||||
|
||||
@@ -2923,6 +2923,10 @@ class AppLocalizationsFr extends AppLocalizations {
|
||||
return 'Le chemin est trop long (maximum $max octets)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Trop de sauts à tracer en une seule requête. Retirez des sauts ou choisissez « Tel que saisi ».';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Cache de carte hors ligne';
|
||||
|
||||
|
||||
@@ -2913,6 +2913,10 @@ class AppLocalizationsHu extends AppLocalizations {
|
||||
return 'Az útvonal túl hosszú (legfeljebb $max bájt)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Túl sok ugrás egyetlen nyomkövetési kéréshez. Távolíts el néhány ugrást, vagy válaszd a „Megadott sorrendben” lehetőséget.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Offline térképgyorsítótár';
|
||||
|
||||
|
||||
@@ -2921,6 +2921,10 @@ class AppLocalizationsIt extends AppLocalizations {
|
||||
return 'Il percorso è troppo lungo (massimo $max byte)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Troppi salti da tracciare in una sola richiesta. Rimuovi alcuni salti o scegli «Come inserito».';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Cache mappa offline';
|
||||
|
||||
|
||||
@@ -2793,6 +2793,10 @@ class AppLocalizationsJa extends AppLocalizations {
|
||||
return '経路が長すぎます(最大 $max バイト)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'1回のリクエストでトレースできるホップ数を超えています。ホップを減らすか、「入力どおり」を選んでください。';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'オフライン用地図キャッシュ';
|
||||
|
||||
|
||||
@@ -2796,6 +2796,10 @@ class AppLocalizationsKo extends AppLocalizations {
|
||||
return '경로가 너무 깁니다(최대 $max바이트)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'한 번의 요청으로 추적하기에는 홉이 너무 많습니다. 홉을 줄이거나 “입력한 대로”를 선택하세요.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => '오프라인 지도 캐시';
|
||||
|
||||
|
||||
@@ -2904,6 +2904,10 @@ class AppLocalizationsNl extends AppLocalizations {
|
||||
return 'Pad is te lang (maximaal $max bytes)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Te veel hops om in één verzoek te tracen. Verwijder enkele hops of kies „Zoals ingevoerd”.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Offline Kaarten Cache';
|
||||
|
||||
|
||||
@@ -2939,6 +2939,10 @@ class AppLocalizationsPl extends AppLocalizations {
|
||||
return 'Ścieżka jest zbyt długa (maksymalnie $max bajtów)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Zbyt wiele skoków do prześledzenia w jednym żądaniu. Usuń część skoków lub wybierz „Jak wprowadzono”.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Pamięć podręczna map offline';
|
||||
|
||||
|
||||
@@ -2915,6 +2915,10 @@ class AppLocalizationsPt extends AppLocalizations {
|
||||
return 'O caminho é muito longo (máximo de $max bytes)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Saltos demais para rastrear em uma única solicitação. Remova alguns saltos ou escolha “Como inserido”.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Cache de Mapa Offline';
|
||||
|
||||
|
||||
@@ -2922,6 +2922,10 @@ class AppLocalizationsRu extends AppLocalizations {
|
||||
return 'Путь слишком длинный (максимум $max байт)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Слишком много хопов для трассировки за один запрос. Удалите часть хопов или выберите «Как введено».';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Кэш офлайн-карты';
|
||||
|
||||
|
||||
@@ -2914,6 +2914,10 @@ class AppLocalizationsSk extends AppLocalizations {
|
||||
return 'Cesta je príliš dlhá (maximum $max bajtov)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Príliš veľa skokov na sledovanie v jednej požiadavke. Odstráňte niektoré skoky alebo zvoľte „Podľa zadania“.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Offline Mapa Pamäť';
|
||||
|
||||
|
||||
@@ -2905,6 +2905,10 @@ class AppLocalizationsSl extends AppLocalizations {
|
||||
return 'Pot je predolga (največ $max bajtov)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Preveč skokov za sledenje v eni zahtevi. Odstranite nekaj skokov ali izberite »Kot vneseno«.';
|
||||
|
||||
@override
|
||||
String get mapCache_title =>
|
||||
'Omrezni predpomnilnik zemljeških zemljejevskih slik';
|
||||
|
||||
@@ -2889,6 +2889,10 @@ class AppLocalizationsSv extends AppLocalizations {
|
||||
return 'Rutten är för lång (högst $max byte)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'För många hopp för att spåra i en enda förfrågan. Ta bort några hopp eller välj ”Som inmatat”.';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Offline Kartcache';
|
||||
|
||||
|
||||
@@ -2915,6 +2915,10 @@ class AppLocalizationsUk extends AppLocalizations {
|
||||
return 'Шлях задовгий (максимум $max байт)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'Забагато хопів для трасування в одному запиті. Видаліть кілька хопів або виберіть «Як введено».';
|
||||
|
||||
@override
|
||||
String get mapCache_title => 'Офлайн-кеш карти';
|
||||
|
||||
|
||||
@@ -2753,6 +2753,10 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
return '路径过长(最多 $max 字节)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get manualTrace_errorTraceTooLong =>
|
||||
'跳数过多,无法在一次请求中追踪。请减少一些跳,或选择“按输入顺序”。';
|
||||
|
||||
@override
|
||||
String get mapCache_title => '离线地图缓存';
|
||||
|
||||
|
||||
@@ -3560,6 +3560,7 @@
|
||||
"manualTrace_errorMixedWidths": "Alle hashes moeten even lang zijn",
|
||||
"manualTrace_errorUnsupportedWidth": "Hashes moeten 1, 2 of 3 bytes zijn (2, 4 of 6 hex-tekens)",
|
||||
"manualTrace_errorTooManyHops": "Pad is te lang (maximaal {max} bytes)",
|
||||
"manualTrace_errorTraceTooLong": "Te veel hops om in één verzoek te tracen. Verwijder enkele hops of kies „Zoals ingevoerd”.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3898,6 +3898,7 @@
|
||||
"manualTrace_errorMixedWidths": "Wszystkie hasze muszą mieć tę samą długość",
|
||||
"manualTrace_errorUnsupportedWidth": "Hasze muszą mieć 1, 2 lub 3 bajty (2, 4 lub 6 znaków szesnastkowych)",
|
||||
"manualTrace_errorTooManyHops": "Ścieżka jest zbyt długa (maksymalnie {max} bajtów)",
|
||||
"manualTrace_errorTraceTooLong": "Zbyt wiele skoków do prześledzenia w jednym żądaniu. Usuń część skoków lub wybierz „Jak wprowadzono”.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3711,6 +3711,7 @@
|
||||
"manualTrace_errorMixedWidths": "Todos os hashes devem ter o mesmo comprimento",
|
||||
"manualTrace_errorUnsupportedWidth": "Os hashes devem ter 1, 2 ou 3 bytes (2, 4 ou 6 caracteres hexadecimais)",
|
||||
"manualTrace_errorTooManyHops": "O caminho é muito longo (máximo de {max} bytes)",
|
||||
"manualTrace_errorTraceTooLong": "Saltos demais para rastrear em uma única solicitação. Remova alguns saltos ou escolha “Como inserido”.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -2956,6 +2956,7 @@
|
||||
"manualTrace_errorMixedWidths": "Все хэши должны быть одной длины",
|
||||
"manualTrace_errorUnsupportedWidth": "Хэши должны быть длиной 1, 2 или 3 байта (2, 4 или 6 шестнадцатеричных символов)",
|
||||
"manualTrace_errorTooManyHops": "Путь слишком длинный (максимум {max} байт)",
|
||||
"manualTrace_errorTraceTooLong": "Слишком много хопов для трассировки за один запрос. Удалите часть хопов или выберите «Как введено».",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3712,6 +3712,7 @@
|
||||
"manualTrace_errorMixedWidths": "Všetky hashe musia mať rovnakú dĺžku",
|
||||
"manualTrace_errorUnsupportedWidth": "Hashe musia mať 1, 2 alebo 3 bajty (2, 4 alebo 6 hexadecimálnych znakov)",
|
||||
"manualTrace_errorTooManyHops": "Cesta je príliš dlhá (maximum {max} bajtov)",
|
||||
"manualTrace_errorTraceTooLong": "Príliš veľa skokov na sledovanie v jednej požiadavke. Odstráňte niektoré skoky alebo zvoľte „Podľa zadania“.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3866,6 +3866,7 @@
|
||||
"manualTrace_errorMixedWidths": "Vse zgoščene vrednosti morajo biti enake dolžine",
|
||||
"manualTrace_errorUnsupportedWidth": "Zgoščene vrednosti morajo imeti 1, 2 ali 3 bajte (2, 4 ali 6 šestnajstiških znakov)",
|
||||
"manualTrace_errorTooManyHops": "Pot je predolga (največ {max} bajtov)",
|
||||
"manualTrace_errorTraceTooLong": "Preveč skokov za sledenje v eni zahtevi. Odstranite nekaj skokov ali izberite »Kot vneseno«.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3706,6 +3706,7 @@
|
||||
"manualTrace_errorMixedWidths": "Alla hashar måste ha samma längd",
|
||||
"manualTrace_errorUnsupportedWidth": "Hashar måste vara 1, 2 eller 3 byte (2, 4 eller 6 hex-tecken)",
|
||||
"manualTrace_errorTooManyHops": "Rutten är för lång (högst {max} byte)",
|
||||
"manualTrace_errorTraceTooLong": "För många hopp för att spåra i en enda förfrågan. Ta bort några hopp eller välj ”Som inmatat”.",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3639,6 +3639,7 @@
|
||||
"manualTrace_errorMixedWidths": "Усі хеші мають бути однакової довжини",
|
||||
"manualTrace_errorUnsupportedWidth": "Хеші мають бути завдовжки 1, 2 або 3 байти (2, 4 або 6 шістнадцяткових символів)",
|
||||
"manualTrace_errorTooManyHops": "Шлях задовгий (максимум {max} байт)",
|
||||
"manualTrace_errorTraceTooLong": "Забагато хопів для трасування в одному запиті. Видаліть кілька хопів або виберіть «Як введено».",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -3716,6 +3716,7 @@
|
||||
"manualTrace_errorMixedWidths": "所有哈希长度必须相同",
|
||||
"manualTrace_errorUnsupportedWidth": "哈希必须为 1、2 或 3 字节(2、4 或 6 个十六进制字符)",
|
||||
"manualTrace_errorTooManyHops": "路径过长(最多 {max} 字节)",
|
||||
"manualTrace_errorTraceTooLong": "跳数过多,无法在一次请求中追踪。请减少一些跳,或选择“按输入顺序”。",
|
||||
"@manualTrace_errorTooManyHops": {
|
||||
"placeholders": {
|
||||
"max": {
|
||||
|
||||
@@ -137,9 +137,13 @@ class _ManualPathTraceScreenState extends State<ManualPathTraceScreen> {
|
||||
connector.pathHashByteWidth,
|
||||
);
|
||||
final input = result.input;
|
||||
final errorText = result.error == null ? null : _errorText(result.error!);
|
||||
final fits =
|
||||
input == null || traceFitsInRequest(input, roundTrip: _returnPath);
|
||||
final errorText = result.error != null
|
||||
? _errorText(result.error!)
|
||||
: (fits ? null : l10n.manualTrace_errorTraceTooLong);
|
||||
final exampleWidth = input?.hopWidth ?? connector.pathHashByteWidth;
|
||||
final canRun = input != null && connector.isConnected;
|
||||
final canRun = input != null && fits && connector.isConnected;
|
||||
const buttonSize = Size(48, 48);
|
||||
|
||||
return Scaffold(
|
||||
|
||||
@@ -444,6 +444,20 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
flags, // flag
|
||||
payload: tracePayload,
|
||||
);
|
||||
if (frame.length > maxFrameSize) {
|
||||
// Too many hops for one request (round trips double them); the radio
|
||||
// would reject or truncate it.
|
||||
appLogger.warn(
|
||||
'Path trace request too large: ${frame.length} bytes',
|
||||
tag: 'PathTraceMapScreen',
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_failed2Loaded = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
_awaitingTraceSent = true;
|
||||
_timeoutTimer?.cancel();
|
||||
// Fallback in case RESP_CODE_SENT / RESP_CODE_ERR never arrives; the
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter_langdetect/flutter_langdetect.dart';
|
||||
|
||||
import '../models/app_settings.dart';
|
||||
import '../models/translation_support.dart';
|
||||
import '../helpers/contact_share_message.dart';
|
||||
import '../helpers/gif_helper.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import 'app_settings_service.dart';
|
||||
@@ -573,6 +574,10 @@ class TranslationService extends ChangeNotifier {
|
||||
if (GifHelper.parseGif(trimmed) != null) {
|
||||
return false;
|
||||
}
|
||||
// A shared contact card is data: translating it would mangle the token.
|
||||
if (parseContactShare(trimmed) != null) {
|
||||
return false;
|
||||
}
|
||||
return !(trimmed.startsWith('m:') ||
|
||||
trimmed.startsWith('V1|') ||
|
||||
trimmed.startsWith('r:'));
|
||||
|
||||
@@ -47,4 +47,28 @@ void main() {
|
||||
final wide = List.filled(22, 'aabbcc').join(',');
|
||||
expect(p(wide).error, PathTraceInputError.tooManyHops);
|
||||
});
|
||||
|
||||
group('traceFitsInRequest', () {
|
||||
PathTraceInput hops(int count, int width) => PathTraceInputParser.parse(
|
||||
List.generate(count, (i) => 'ab' * width).join(','),
|
||||
width,
|
||||
).input!;
|
||||
|
||||
test('round trip of 21 three-byte hops exceeds the frame limit', () {
|
||||
// 41 hops x 4-byte trace prefixes + 10-byte header = 174 > 172.
|
||||
expect(traceFitsInRequest(hops(21, 3), roundTrip: true), isFalse);
|
||||
expect(traceFitsInRequest(hops(21, 3), roundTrip: false), isTrue);
|
||||
});
|
||||
|
||||
test('round trip of 20 three-byte hops fits', () {
|
||||
// 39 x 4 + 10 = 166.
|
||||
expect(traceFitsInRequest(hops(20, 3), roundTrip: true), isTrue);
|
||||
});
|
||||
|
||||
test('hop count is capped at 64 even when bytes fit', () {
|
||||
// 33 one-byte hops round trip = 65 hops.
|
||||
expect(traceFitsInRequest(hops(33, 1), roundTrip: true), isFalse);
|
||||
expect(traceFitsInRequest(hops(32, 1), roundTrip: true), isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/services/app_settings_service.dart';
|
||||
import 'package:meshcore_open/services/translation_service.dart';
|
||||
import 'package:meshcore_open/storage/prefs_manager.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test('outgoing translation skips contact-share tokens', () async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await PrefsManager.initialize();
|
||||
final settings = AppSettingsService();
|
||||
await settings.loadSettings();
|
||||
await settings.setComposerTranslationEnabled(true);
|
||||
final translation = TranslationService(settings);
|
||||
const token =
|
||||
'<50ba28f599799142622d188469a63f3890d495cdcedd24239052abd364c0283d:1:CC>';
|
||||
|
||||
expect(
|
||||
translation.shouldTranslateOutgoing(
|
||||
text: token,
|
||||
targetLanguageCode: 'de',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
translation.shouldTranslateOutgoing(
|
||||
text: 'hello there',
|
||||
targetLanguageCode: 'de',
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user