fix(shopinbit): don't pass non-ASCII chars in countryLabels
What changed, and why it matters
This commit fixes a bug in Stack Wallet's ShopInBit feature where country names containing special characters (like 'Åland Islands') were being corrupted when sent to a server. The fix replaces the full country name with the two-letter ISO country code in the request description, preventing the corruption. This is a data-integrity bug rather than a traditional security vulnerability, but it could cause orders to be submitted with unreadable or incorrect destination country information.
No immediate security response is required. The fix should be verified by testing submissions with countries containing non-ASCII characters across all three categories. Consider auditing other HttpClient.write() usages in the codebase for similar encoding issues and ensuring the backend can interpret ISO country codes in request descriptions.
Security signals we found
Encoding mismatch between UTF-8 JSON and Latin-1 character encoding
Non-ASCII input corruption in HTTP request body
Potential downstream parsing failure or misrouting of order data
Data integrity issue in third-party service integration
Evidence from the diff
The patch addresses an encoding issue where Dart’s HttpClientRequest.write() encodes non-ASCII characters as Latin-1, corrupting JSON bodies on mobile. Previously, the code looked up a human-readable country label (e.g., ‘Åland Islands’) from a list and included it in the requestDescription. Now it uses the ISO country code directly. The change removes duplicated label-lookup code across concierge, car, and travel categories and consistently uses _selectedCountryIso. This prevents mojibake/encoding corruption in the structured comment sent to the ShopInBit backend.
Changed components
lib/pages/shopinbit/shopinbit_step_4.dartShopInBit concierge category submissionShopInBit car category submissionShopInBit travel category submissionHttpClient request body encoding pathInspect captured patch +8 / −19
diff --git a/lib/pages/shopinbit/shopinbit_step_4.dart b/lib/pages/shopinbit/shopinbit_step_4.dart
index 88211b6..8231417 100644
--- a/lib/pages/shopinbit/shopinbit_step_4.dart
+++ b/lib/pages/shopinbit/shopinbit_step_4.dart
@@ -459,39 +459,28 @@ class _ShopInBitStep4State extends State<ShopInBitStep4> {
}
Future<void> _submit() async {
- // Format structured comment for Concierge
+ // Format structured comment per category.
+ // Use ISO code for delivery country in comment: country labels can
+ // contain non-ASCII (e.g. "Åland Islands") which HttpClientRequest.write()
+ // encodes as Latin-1, corrupting the JSON body on mobile.
+ final countryIso = _selectedCountryIso!;
if (widget.model.category == ShopInBitCategory.concierge) {
final budgetText =
_noLimit ? "No limit" : "${_budgetController.text.trim()} EUR";
- final countryLabel = _countries
- .where((c) => c['iso'] == _selectedCountryIso)
- .map((c) => c['label'] as String)
- .firstOrNull ??
- _selectedCountryIso!;
widget.model.requestDescription =
"What to purchase: ${_whatToPurchaseController.text.trim()}\n"
"Condition: $_selectedCondition\n"
"Budget: $budgetText\n"
- "Delivery country: $countryLabel";
+ "Delivery country: $countryIso";
} else if (widget.model.category == ShopInBitCategory.car) {
- final countryLabel = _countries
- .where((c) => c['iso'] == _selectedCountryIso)
- .map((c) => c['label'] as String)
- .firstOrNull ??
- _selectedCountryIso!;
widget.model.requestDescription =
"Brand: ${_brandController.text.trim()}\n"
"Model: ${_modelController.text.trim()}\n"
"Condition: $_selectedCarCondition\n"
"Description: ${_carDescriptionController.text.trim()}\n"
"Budget: ${_carBudgetController.text.trim()} EUR\n"
- "Delivery country: $countryLabel";
+ "Delivery country: $countryIso";
} else if (widget.model.category == ShopInBitCategory.travel) {
- final countryLabel = _countries
- .where((c) => c['iso'] == _selectedCountryIso)
- .map((c) => c['label'] as String)
- .firstOrNull ??
- _selectedCountryIso!;
final parts = <String>[
"Arrangement: $_selectedArrangement",
@@ -534,7 +523,7 @@ class _ShopInBitStep4State extends State<ShopInBitStep4> {
parts.add("Travelers: ${travelers.join(', ')}");
parts.add("Budget: ${_travelBudgetController.text.trim()} EUR");
- parts.add("Delivery country: $countryLabel");
+ parts.add("Delivery country: $countryIso");
widget.model.requestDescription = parts.join("\n");
} else {
Why this scored 37/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.