8000 new language selector by Ruchika4 · Pull Request #4343 · adobecom/milo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

new language selector #4343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 62 commits into from
Jun 9, 2025
Merged

new language selector #4343

merged 62 commits into from
Jun 9, 2025

Conversation

Ruchika4
Copy link
Contributor
@Ruchika4 Ruchika4 commented Jun 9, 2025
  • Add your
  • Specific
  • Features or fixes

Resolves: MWPW-NUMBER

Test URLs:

GNav Test URLs

Gnav + Footer + Region Picker modal:

Thin Gnav + ThinFooter + Region Picker dropup:

Localnav + Promo:

Sticky Branch Banner:

Inline Branch Banner:

Blog

RTL Locale

Copy link
Contributor
aem-code-sync bot commented Jun 9, 2025

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

@Ruchika4 Ruchika4 merged commit defed5e into MWPW-169805 Jun 9, 2025
9 of 11 checks passed
@Ruchika4 Ruchika4 deleted the finalbkp-nls branch June 9, 2025 15:07
Copy link
Contributor
aem-code-sync bot commented Jun 9, 2025
Page Scores Audits Google
📱 /drafts/blaishram/test-urls/page?martech=off Lighthouse returned error: Something went wrong. PSI
🖥️ /drafts/blaishram/test-urls/page?martech=off Lighthouse returned error: FAILED_DOCUMENT_REQUEST. Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Details: net::ERR_TIMED_OUT) PSI
📱 /drafts/blaishram/test-urls/page-gnav-footer-thin?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /drafts/blaishram/test-urls/page-gnav-footer-thin?martech=off Lighthouse returned error: FAILED_DOCUMENT_REQUEST. Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Details: net::ERR_TIMED_OUT) PSI
📱 /drafts/blaishram/test-urls/page-with-promo?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /drafts/blaishram/test-urls/page-with-promo?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Comment on lines +100 to +107
searchContainer.innerHTML = `
<div class="search-input-wrapper">
<svg class="search-icon" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14.8243 13.9758L10.7577 9.90923C11.5332 8.94809 12 7.72807 12 6.40005C12 3.31254 9.48755 0.800049 6.40005 0.800049C3.31254 0.800049 0.800049 3.31254 0.800049 6.40004C0.800049 9.48755 3.31254 12 6.40005 12C7.72807 12 8.9481 11.5331 9.90922 10.7577L13.9758 14.8243C14.093 14.9414 14.2461 15 14.4 15C14.5539 15 14.7071 14.9414 14.8243 14.8243C15.0586 14.5899 15.0586 14.2102 14.8243 13.9758ZM6.40005 10.8C3.97426 10.8 2.00005 8.82582 2.00005 6.40004C2.00005 3.97426 3.97426 2.00004 6.40005 2.00004C8.82583 2.00004 10.8 3.97426 10.8 6.40004C10.8 8.82582 8.82583 10.8 6.40005 10.8Z" fill="#666"/>
</svg>
<input type="text" placeholder="${placeholderText}" class="search-input" id="language-selector-search" aria-autocomplete="list" aria-controls="language-selector-listbox" autocomplete="off" />
</div>
`;

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI about 1 month ago

To fix the issue, we need to ensure that the placeholderText is properly escaped before being interpolated into the HTML string. This can be achieved by using a utility function to encode special HTML characters (e.g., <, >, &, "). This will prevent any malicious content from being interpreted as HTML or JavaScript.

The best approach is to:

  1. Introduce an HTML-escaping utility function if one does not already exist in the codebase.
  2. Use this function to sanitize placeholderText before it is interpolated into the HTML string on line 100.

Suggested changeset 1
libs/blocks/language-selector/language-selector.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/libs/blocks/language-selector/language-selector.js b/libs/blocks/language-selector/language-selector.js
--- a/libs/blocks/language-selector/language-selector.js
+++ b/libs/blocks/language-selector/language-selector.js
@@ -91,2 +91,12 @@
 function createDropdownElements(placeholderText) {
+  const escapeHTML = (str) => str.replace(/[&<>"']/g, (char) => ({
+    '&': '&amp;',
+    '<': '&lt;',
+    '>': '&gt;',
+    '"': '&quot;',
+    "'": '&#39;',
+  }[char]));
+
+  const sanitizedPlaceholderText = escapeHTML(placeholderText);
+
   const dropdown = createTag('div');
@@ -104,3 +114,3 @@
       </svg>
-      <input type="text" placeholder="${placeholderText}" class="search-input" id="language-selector-search" aria-autocomplete="list" aria-controls="language-selector-listbox" autocomplete="off" />
+      <input type="text" placeholder="${sanitizedPlaceholderText}" class="search-input" id="language-selector-search" aria-autocomplete="list" aria-controls="language-selector-listbox" autocomplete="off" />
     </div>
@@ -113,3 +123,3 @@
     tabindex: '0',
-    'aria-label': placeholderText,
+    'aria-label': sanitizedPlaceholderText,
   });
EOF
@@ -91,2 +91,12 @@
function createDropdownElements(placeholderText) {
const escapeHTML = (str) => str.replace(/[&<>"']/g, (char) => ({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
}[char]));

const sanitizedPlaceholderText = escapeHTML(placeholderText);

const dropdown = createTag('div');
@@ -104,3 +114,3 @@
</svg>
<input type="text" placeholder="${placeholderText}" class="search-input" id="language-selector-search" aria-autocomplete="list" aria-controls="language-selector-listbox" autocomplete="off" />
<input type="text" placeholder="${sanitizedPlaceholderText}" class="search-input" id="language-selector-search" aria-autocomplete="list" aria-controls="language-selector-listbox" autocomplete="off" />
</div>
@@ -113,3 +123,3 @@
tabindex: '0',
'aria-label': placeholderText,
'aria-label': sanitizedPlaceholderText,
});
Copilot is powered by AI and may make mistakes. Always verify output.
milo-pr-merge bot pushed a commit that referenced this pull request Jun 11, 2025
* new language selector (#4343)

* language-selector

* language-selector

* fix lan selector

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* libs/blocks/language-selector/language-selector.js

* wip

* wip

* fix existing page issue

* Update language-selector.js

* Update language-selector.js

* Update language-selector.css

* Update language-selector.css

* Update language-selector.css

* Update language-selector.js

* Update language-selector.js

* Update language-selector.css

* Update language-selector.js

* Update language-selector.css

* Update language-selector.js

* Update language-selector.css

* Update language-selector.js

* Update language-selector.js

* Update language-selector.css

* show localize search text

* fix tabbing and key up/down

* add unit test

* Code optimization (#4289)

Update language-selector.js

* Update language-selector.css

* Update language-selector.js

* Update language-selector.css

* Update language-selector.css

* Update language-selector.js

* Update language-selector.css

* Update language-selector.js

* Update language-selector.css

* Update language-selector.css

* Update language-selector.css

* Update language-selector.css

* Update language-selector.css

* Update language-selector.css

* Update language-selector.css

* Update language-selector.css

* Css nls (#4318)

* Update language-selector.css

* Update language-selector.css

* Update language-selector.css

* Update language-selector.js

* Final nls (#4320)

* Update language-selector.js

* Update language-selector.test.js

* Update language-selector.css

* Update language-selector.js

* Update language-selector.css

* Update language-selector.css

* Update language-selector.js

* Update language-selector.js

* Keyboard navigation fix

* add esc and focus out event to close the language selector dropdown

* fix unit test

---------

Co-authored-by: Bandana Laishram <bandanalaishram@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0