bito-code-review[bot] commented on code in PR #43397:
URL: https://github.com/apache/superset/pull/43397#discussion_r3832204537


##########
superset-frontend/plugins/plugin-chart-cartodiagram/test/util/layerUtil.test.ts:
##########
@@ -17,22 +17,51 @@
  * under the License.
  */
 
-import { WfsLayerConf } from '../../src/types';
+import { WfsLayerConf, XyzLayerConf } from '../../src/types';
 import {
   createLayer,
   createWfsLayer,
   createWmsLayer,
   createXyzLayer,
+  escapeAttribution,
 } from '../../src/util/layerUtil';
 
 describe('layerUtil', () => {
+  describe('escapeAttribution', () => {
+    test('escapes HTML markup in attribution strings', () => {
+      expect(escapeAttribution('(c) OSM <img src=x onerror=alert(1)>')).toBe(
+        '(c) OSM &lt;img src=x onerror=alert(1)&gt;',
+      );
+      expect(escapeAttribution('a & "b" \'c\'')).toBe(
+        'a &amp; &quot;b&quot; &#039;c&#039;',
+      );
+      expect(escapeAttribution(undefined)).toBeUndefined();
+    });
+  });
+
   describe('createWmsLayer', () => {
     test('exists', () => {
       // function is trivial
       expect(createWmsLayer).toBeDefined();
     });
   });

Review Comment:
   <!-- Bito Reply -->
   The addition of the attribution-escaping test for `createWmsLayer` is 
appropriate and aligns with the existing testing pattern for `createXyzLayer`. 
This change ensures that HTML markup in attribution strings is correctly 
escaped, addressing the security concern raised in the review.
   
   
**superset-frontend/plugins/plugin-chart-cartodiagram/test/util/layerUtil.test.ts**
   ```
   describe('createWmsLayer', () => {
       test('exists', () => {
         // function is trivial
         expect(createWmsLayer).toBeDefined();
       });
     });
   ```



-- 
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