@atlassian/i18n-properties-loader 2.0.0 → 2.0.1-8db0611

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +11 -9
  2. package/index.js +38 -7
  3. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -3,20 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [2.0.0](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/i18n-properties-loader@2.0.0..@atlassian/i18n-properties-loader@1.1.7) (2026-04-29)
6
+ ## [2.0.1](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/i18n-properties-loader@2.0.1..@atlassian/i18n-properties-loader@2.0.0) (2026-05-12)
7
7
 
8
+ **Note:** Version bump only for package @atlassian/i18n-properties-loader
8
9
 
9
- ### ⚠ BREAKING CHANGES
10
10
 
11
- * drop webpack 4 support
12
11
 
13
- ### Miscellaneous Chores
14
12
 
15
- * drop Webpack 4 support mention ([3c2c394](https://bitbucket.org/atlassianlabs/fe-server/commits/3c2c394d2f4be0c95d20c27e107a6b1d8f3e5ac4))
16
13
 
14
+ ## [2.0.0](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/i18n-properties-loader@2.0.0..@atlassian/i18n-properties-loader@1.1.7) (2026-04-29)
17
15
 
18
16
 
19
- ## <small>1.1.7 (2026-04-09)</small>
17
+ ### BREAKING CHANGES
18
+
19
+ * drop webpack 4 support
20
+
21
+ ### [1.1.7](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/i18n-properties-loader@1.1.7..@atlassian/i18n-properties-loader@1.1.6) (2026-04-09)
20
22
 
21
23
  * [Renovate] Update frontend - webpack ([b693f8c](https://bitbucket.org/atlassianlabs/fe-server/commits/b693f8c))
22
24
 
@@ -24,7 +26,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
24
26
 
25
27
 
26
28
 
27
- ## <small>1.1.6 (2026-02-23)</small>
29
+ ### [1.1.6](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/i18n-properties-loader@1.1.6..@atlassian/i18n-properties-loader@1.1.5) (2026-02-23)
28
30
 
29
31
  **Note:** Version bump only for package @atlassian/i18n-properties-loader
30
32
 
@@ -32,7 +34,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
32
34
 
33
35
 
34
36
 
35
- ## <small>1.1.5 (2026-02-21)</small>
37
+ ### [1.1.5](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/i18n-properties-loader@1.1.5..@atlassian/i18n-properties-loader@1.1.4) (2026-02-21)
36
38
 
37
39
  **Note:** Version bump only for package @atlassian/i18n-properties-loader
38
40
 
@@ -40,7 +42,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
40
42
 
41
43
 
42
44
 
43
- ## <small>1.1.4 (2026-02-20)</small>
45
+ ### [1.1.4](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/i18n-properties-loader@1.1.4..@atlassian/i18n-properties-loader@1.1.3) (2026-02-20)
44
46
 
45
47
  **Note:** Version bump only for package @atlassian/i18n-properties-loader
46
48
 
package/index.js CHANGED
@@ -97,6 +97,29 @@ const clearCacheWhenIdle = debounce(() => {
97
97
  i18nCache = new Map();
98
98
  }, accessThreshold);
99
99
 
100
+ // Returns the quote character (' or ") enclosing `offset` in `source`, or null if not in a string literal.
101
+ function getEnclosingStringQuote(source, offset) {
102
+ let openQuote = null; // currently open string delimiter, or null
103
+ let escaped = false;
104
+ for (let i = 0; i < offset; i++) {
105
+ const ch = source[i];
106
+ if (escaped) {
107
+ escaped = false;
108
+ } else if (ch === '\\') {
109
+ escaped = true;
110
+ } else if (openQuote) {
111
+ if (ch === openQuote) openQuote = null;
112
+ } else if (ch === "'" || ch === '"') {
113
+ openQuote = ch;
114
+ }
115
+ }
116
+ return openQuote;
117
+ }
118
+
119
+ function escapeForStringLiteral(value, quote) {
120
+ return value.split(quote).join('\\' + quote);
121
+ }
122
+
100
123
  function processI18nFiles(i18nFiles) {
101
124
  clearCacheWhenIdle();
102
125
 
@@ -152,8 +175,18 @@ module.exports = function (source, map) {
152
175
 
153
176
  // Replace "I18n.getText('some.translation.key', [param1], [paramN])" with the real translation string
154
177
  const properties = processI18nFiles(i18nFiles);
155
- const newSource = source.replace(i18nRegExp, (...args) => {
156
- const { namespace, key, endParam } = args.pop();
178
+ const newSource = source.replace(i18nRegExp, (match, ...args) => {
179
+ // replace() callback: (match, ...captures, offset, source, groups)
180
+ const groups = args[args.length - 1];
181
+ const matchSource = args[args.length - 2];
182
+ const offset = args[args.length - 3];
183
+
184
+ // Escape substitutions inside string literals (e.g. babel-plugin-istanbul's
185
+ // embedded inputSourceMap.sourcesContent) to avoid breaking the surrounding
186
+ // literal with unescaped quotes from JSON.stringify(message). See: DCA11Y-3344
187
+ const enclosingQuote = getEnclosingStringQuote(matchSource, offset);
188
+
189
+ const { namespace, key, endParam } = groups;
157
190
  const escapedKey = key.replace(/\s/g, '\\ ');
158
191
 
159
192
  let message = properties.get(escapedKey);
@@ -171,12 +204,10 @@ module.exports = function (source, map) {
171
204
  // Output string
172
205
  const escapedMessage = JSON.stringify(message);
173
206
 
174
- if (endParam === ',') {
175
- // We don't need to unquote the string since the WRM.format function has all the logic to do that
176
- return `${formatFunctionCall}(${escapedMessage},`;
177
- }
207
+ // For endParam === ',' we don't unquote — WRM.format handles unquoting
208
+ const result = endParam === ',' ? `${formatFunctionCall}(${escapedMessage},` : unquoteMessage(escapedMessage);
178
209
 
179
- return unquoteMessage(escapedMessage);
210
+ return enclosingQuote ? escapeForStringLiteral(result, enclosingQuote) : result;
180
211
  });
181
212
 
182
213
  callback(null, newSource, map);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlassian/i18n-properties-loader",
3
- "version": "2.0.0",
3
+ "version": "2.0.1-8db0611",
4
4
  "description": "A webpack loader for i18n *.properties files that can be used in Atlassian Server products",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -46,12 +46,12 @@
46
46
  "webpack": "^5.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@atlassian/webresource-webpack-plugin": "^7.1.7",
49
+ "@atlassian/webresource-webpack-plugin": "^7.1.8",
50
50
  "jest": "30.2.0",
51
51
  "webpack": "5.105.4"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=12"
55
55
  },
56
- "gitHead": "256c4a629fc4768ee9f47f313961738d41640a06"
56
+ "gitHead": "ddd662a8e9aa2d54c2c3bc086f1a32874e325594"
57
57
  }