rusackas opened a new pull request, #42103:
URL: https://github.com/apache/superset/pull/42103

   ### SUMMARY
   
   `scripts/translations/backfill_po.py` validates the `--lang` code before it 
lands in a filesystem path. The pattern only allowed an optional `_<REGION>` 
subtag:
   
   ```
   [a-z]{2,3}(_[A-Z]{2})?
   ```
   
   That rejects catalogs whose code carries an ISO 15924 **script** subtag — 
most notably `sr_Latn` (Serbian in Latin script), which exists in 
`superset/translations/`. Running `backfill_po.py --lang sr_Latn` failed with 
`Invalid language code`, so the backfill silently skipped that catalog (I hit 
exactly this while backfilling gaps — `sr_Latn` came back with 0 entries filled 
and no obvious error).
   
   This widens the pattern to also accept a titlecase script subtag and pulls 
the check into a small `_is_valid_lang_code` helper so it's unit-testable:
   
   ```
   [a-z]{2,3}(_([A-Z]{2}|[A-Z][a-z]{3}))?
   ```
   
   Path-traversal protection is unchanged (`fullmatch`, same character classes).
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest tests/unit_tests/scripts/translations/backfill_po_test.py
   ```
   
   New tests cover `fr` / `pt_BR` / `sr_Latn` (accepted) and malformed / 
traversal inputs like `fr_br`, `../etc`, `sr-Latn` (rejected).
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Changes UI
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to