You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FIX] manifestEnhancer: Only use valid files for supportedLocales (#1080)
This fixes two problems that could have occurred:
A properties file with an invalid locale was still taken into the list
of supported locales, which then caused a runtime exception in the
ResourceBundle as it validates the input.
Another problem was that properties files could have a valid name
according to BCP47, but the file won't be ever requested with that name.
This is due to the fact that the ResourceBundle does use the legacy Java
locale format (using underscores instead of dashes) for the request URL.
In both cases, the properties file is now ignored and no entry for the
supportedLocales is created.
Only locales that are valid according to the legacy Java locale format
are considered.
However, there is one special case: sr_Latn is also requested by the UI5
runtime, although it contains a BCP47 script, which is not valid
according to the legacy Java locale format.
---------
Co-authored-by: Merlin Beutlberger <m.beutlberger@sap.com>
Copy file name to clipboardExpand all lines: test/lib/processors/manifestEnhancer.js
+172-6Lines changed: 172 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,34 @@ import test from "ava";
2
2
importsinonGlobalfrom"sinon";
3
3
importesmockfrom"esmock";
4
4
5
+
functionisValidBCP47Locale(locale){
6
+
if(locale===""){
7
+
// Special handling of empty string, as this marks the developer locale (without locale information)
8
+
returntrue;
9
+
}
10
+
11
+
// See https://github.com/SAP/openui5/blob/a8f36e430f1fac172eb705811da4a2af25483408/src/sap.ui.core/src/sap/base/i18n/ResourceBundle.js#L30
12
+
/**
13
+
* A regular expression that describes language tags according to BCP-47.
14
+
*
15
+
* @see BCP47 "Tags for Identifying Languages" (http://www.ietf.org/rfc/bcp/bcp47.txt)
16
+
*
17
+
* The matching groups are
18
+
* 0=all
19
+
* 1=language (shortest ISO639 code + ext. language sub tags | 4digits (reserved) | registered language sub tags)
20
+
* 2=script (4 letters)
21
+
* 3=region (2letter language or 3 digits)
22
+
* 4=variants (separated by '-', Note: capturing group contains leading '-' to shorten the regex!)
23
+
* 5=extensions (including leading singleton, multiple extensions separated by '-')
24
+
* 6=private use section (including leading 'x', multiple sections separated by '-')
25
+
*/
26
+
27
+
// eslint-disable-next-line max-len
28
+
// [-------------------- language ----------------------][--- script ---][------- region --------][------------- variants --------------][----------- extensions ------------][------ private use -------]
0 commit comments