Skip to content

Conversation

@Saksham-Sirohi
Copy link
Contributor

@Saksham-Sirohi Saksham-Sirohi commented Nov 12, 2025

Fixes youtube error

Summary by Sourcery

Unify referrer policy configuration across front-end, back-end, and server; enhance YouTube iframe embeds with proper origin parameters and conditional privacy-enhanced mode; and tighten X-Frame-OptionsMiddleware logic for improved security.

Bug Fixes:

  • Fix YouTube iframe errors by setting Referrer-Policy on all embedded iframes and related headers

Enhancements:

  • Export REFERRER_POLICY constant from api library and apply it in Vue components and nginx config
  • Include window.location.origin in YouTube embed URLs and support privacy-enhanced mode with youtube-nocookie domain
  • Add getPlayerOrigin helper to safely retrieve origin for embed URLs
  • Refine XFrameOptionsMiddleware to conditionally set X-Frame-Options and add Referrer-Policy headers only when needed

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 12, 2025

Reviewer's Guide

Implements a strict-origin-when-cross-origin referrer policy end-to-end (client iframes, middleware, Nginx) and refines YouTube embed URL construction by adding origin parameters and respecting privacy mode, while tightening frame-options logic.

Entity relationship diagram for HTTP response headers

erDiagram
    RESPONSE_HEADERS {
        X-Frame-Options string
        Referrer-Policy string
    }
    RESPONSE_HEADERS ||--o| REQUEST : sets
    RESPONSE_HEADERS ||--o| REFERRER_POLICY : uses
Loading

Class diagram for updated MediaSource component

classDiagram
    class MediaSource {
        +languageIframeUrl: String
        +referrerPolicy: String
        +getYoutubeUrl(ytid, autoplay, mute, hideControls, noRelated, showinfo, disableKb, loop, modestBranding, enablePrivacyEnhancedMode)
        +getLanguageIframeUrl(languageUrl, enablePrivacyEnhancedMode)
        +getPlayerOrigin()
    }
    MediaSource --> JanusCall
    MediaSource --> JanusChannelCall
    MediaSource --> Livestream
Loading

Class diagram for updated XFrameOptionsMiddleware

classDiagram
    class XFrameOptionsMiddleware {
        +process_response(request, response)
    }
    XFrameOptionsMiddleware --> REFERRER_POLICY
Loading

Class diagram for updated api.js export

classDiagram
    class api {
        +connect(token, clientId, inviteToken)
    }
    class REFERRER_POLICY {
        <<constant>>
    }
    api ..> REFERRER_POLICY
Loading

File-Level Changes

Change Details Files
Centralize and apply REFERRER_POLICY across client components, server middleware, and Nginx
  • Export REFERRER_POLICY constant in lib/api.js
  • Import REFERRER_POLICY in Vue data and assign to referrerPolicy property
  • Bind referrerpolicy attribute on static templates and dynamically created iframes
  • In XFrameOptionsMiddleware, define REFERRER_POLICY and add Referrer-Policy header when missing
  • Update nginx.conf to use strict-origin-when-cross-origin for Referrer-Policy
webapp/src/lib/api.js
webapp/src/components/MediaSource.vue
webapp/src/views/exhibitors/item.vue
server/venueless/middleware.py
prod/nginx.conf
Enhance YouTube iframe URL generation with origin and privacy settings
  • Add getPlayerOrigin method to safely retrieve window.location.origin
  • Include origin parameter in getYoutubeUrl and getLanguageIframeUrl when available
  • Update getLanguageIframeUrl signature and invocation to accept enablePrivacyEnhancedMode flag
webapp/src/components/MediaSource.vue

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `server/venueless/middleware.py:9` </location>
<code_context>
-        # We don't use xframe_options_exempt here since that doesn't catch error pages
-        if request.path.startswith("/zoom"):
-            return response
+        if response.get("X-Frame-Options") is None:
+            # Don't set it if they used @xframe_options_exempt
+            if not getattr(response, "xframe_options_exempt", False) and not request.path.startswith(
</code_context>

<issue_to_address>
**🚨 issue (security):** Logic for setting X-Frame-Options has changed and may now skip setting the header in more cases.

Please verify that the updated logic does not permit framing when the header should be set but is missing, as this differs from the previous behavior.
</issue_to_address>

### Comment 2
<location> `server/venueless/middleware.py:9-14` </location>
<code_context>
        if response.get("X-Frame-Options") is None:
            # Don't set it if they used @xframe_options_exempt
            if not getattr(response, "xframe_options_exempt", False) and not request.path.startswith(
                "/zoom"
            ):
                response["X-Frame-Options"] = "DENY"

</code_context>

<issue_to_address>
**suggestion (code-quality):** Merge nested if conditions ([`merge-nested-ifs`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/merge-nested-ifs))

```suggestion
        if response.get("X-Frame-Options") is None and (not getattr(response, "xframe_options_exempt", False) and not request.path.startswith(
                        "/zoom"
                    )):
            response["X-Frame-Options"] = "DENY"

```

<br/><details><summary>Explanation</summary>Too much nesting can make code difficult to understand, and this is especially
true in Python, where there are no brackets to help out with the delineation of
different nesting levels.

Reading deeply nested code is confusing, since you have to keep track of which
conditions relate to which levels. We therefore strive to reduce nesting where
possible, and the situation where two `if` conditions can be combined using
`and` is an easy win.
</details>
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@mariobehling mariobehling merged commit 9254dd3 into fossasia:development Nov 14, 2025
2 of 9 checks passed
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.

3 participants