Skip to content
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

✨ Improve iframe display #842

Open
wants to merge 2 commits into
base: preprod
Choose a base branch
from
Open

✨ Improve iframe display #842

wants to merge 2 commits into from

Conversation

bjlaa
Copy link
Contributor

@bjlaa bjlaa commented Feb 6, 2025

No description provided.

@bjlaa bjlaa self-assigned this Feb 6, 2025
Copy link

Le Monde / Bug UX / UI

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nosgestesclimat ✅ Ready (Inspect) Visit Preview Feb 6, 2025 10:35am

Copy link

github-actions bot commented Feb 6, 2025

Report for the pull request #842


🌐 Translation status

UI's texts

Language Nb. missing translations Status
en Ø ✔️
es Ø ✔️

FAQ's questions

Language Nb. missing translations Status
en Ø ✔️
es Ø ✔️

You will find more information about the translation in the dedicated file.

}
})

window.addEventListener('message', function (evt) {

Check warning

Code scanning / CodeQL

Missing origin verification in `postMessage` handler Medium

Postmessage handler has no origin check.

Copilot Autofix AI 2 days ago

To fix the problem, we need to verify the origin of incoming messages in the postMessage handler. This involves checking the origin property of the event object against a list of trusted origins before processing the message. This ensures that only messages from trusted sources are handled, mitigating the risk of malicious messages.

  1. Identify the trusted origins that are allowed to send messages.
  2. Modify the postMessage handler to include a check for the origin property.
  3. Only process the message if the origin is in the list of trusted origins.
Suggested changeset 1
public/iframeSimulation.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/public/iframeSimulation.js b/public/iframeSimulation.js
--- a/public/iframeSimulation.js
+++ b/public/iframeSimulation.js
@@ -80,7 +80,10 @@
   window.addEventListener('message', function (evt) {
-    if (
-      evt.data.kind === 'resize-height' &&
-      iframe.style.height !== `${evt.data.value}px`
-    ) {
-      iframe.style.height = `${evt.data.value}px`
+    const trustedOrigins = ['https://www.example.com', 'https://nosgestesclimat.fr'];
+    if (trustedOrigins.includes(evt.origin)) {
+      if (
+        evt.data.kind === 'resize-height' &&
+        iframe.style.height !== `${evt.data.value}px`
+      ) {
+        iframe.style.height = `${evt.data.value}px`
+      }
     }
EOF
@@ -80,7 +80,10 @@
window.addEventListener('message', function (evt) {
if (
evt.data.kind === 'resize-height' &&
iframe.style.height !== `${evt.data.value}px`
) {
iframe.style.height = `${evt.data.value}px`
const trustedOrigins = ['https://www.example.com', 'https://nosgestesclimat.fr'];
if (trustedOrigins.includes(evt.origin)) {
if (
evt.data.kind === 'resize-height' &&
iframe.style.height !== `${evt.data.value}px`
) {
iframe.style.height = `${evt.data.value}px`
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@Clemog
Copy link
Contributor

Clemog commented Feb 7, 2025

  • J'ai vérifié le fonctionnement sur l'iframe du Monde, j'ai l'impression qu'il faudrait mettre une valeur par défaut pour maxHeight sinon on a toujours le souci du scroll (peut etre à 600 ?)
  • Et je n'arrive pas à faire apparaitre la home (comme pour demo-iframeSimulation) sur leur site ..
  • Et on a toujours le scroll pour le tuto

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.

2 participants