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

[ CTAブロック ] iframeで配置したGoogleマップが表示されない #1164

Open
mtdkei opened this issue Jan 31, 2025 · 6 comments
Open
Assignees

Comments

@mtdkei
Copy link
Contributor

mtdkei commented Jan 31, 2025

CTAブロックに登録したiframeのGoogleマップですが https://demo.dev3.biz/lightning-g3/ でも再現できました。
(ログインをした人だけ表示されるようにしてます。)

また、以下でも同様の確認ができました。

  • カスタムHTMLではなくビジュアル埋め込みブロックを使った時
  • ウィジェットエリア → 固定ページにCTAブロックを貼り付けた時
  • テーマをTT5とTT1に変えた時
  • ExUnitを削除して再インストールした時
  • ExUnit以外のプラグインを停止した時

ただ、ものによってはGooglemapが表示されるので、原因が掴めてません。
従来のウィジェットのCTAなら表示されます。
Image

@kurudrive
Copy link
Member

結局最終出力側が iframe を許可してるかどうかのような気がするのよなぁ...

@mtdkei
Copy link
Contributor Author

mtdkei commented Jan 31, 2025

@kurudrive
ありがとうございます!とりあえず https://demo.dev3.biz/lightning-g3/cta%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9Fcta%E5%9C%B0%E5%9B%B3%E8%A1%A8%E7%A4%BA%E3%83%86%E3%82%B9%E3%83%88/ のコンソールを見てみたら以下のエラーが出てきたので、最終出力側が iframe を許可してるかどうかを含めてみてみようと思います。

[Deprecation] Listener added for a 'DOMSubtreeModified' mutation event. Support for this event type has been removed, and this event will no longer be fired. See https://chromestatus.com/feature/5083947249172480 for more information.
i @ eK0bnzmYG5g.js:280Understand this errorAI
ZiVps04q:1 
        
        
       Failed to load resource: the server responded with a status of 404 ()Understand this errorAI
ZiVps04q:1 
        
        
       Failed to load resource: the server responded with a status of 404 ()Understand this errorAI
ZiVps04q:1 
        
        
       Failed to load resource: the server responded with a status of 404 ()Understand this errorAI
ZiVps04q:1 
        
        
       Failed to load resource: the server responded with a status of 404 ()Understand this errorAI
main.js?ver=15.29.4:1 Uncaught SecurityError: Failed to read a named property 'document' from 'Window': Blocked a frame with origin "https://demo.dev3.biz" from accessing a cross-origin frame.
    at HTMLCollection.forEach (<anonymous>)
    at d (main.js?ver=15.29.4:1:1984)
d @ main.js?ver=15.29.4:1
setTimeout
(anonymous) @ main.js?ver=15.29.4:1

@kurudrive
Copy link
Member

CTAブロックは

で wp_kses_post() 経由してるから iframe を弾いてる空気を感じます(・w・

@mtdkei
Copy link
Contributor Author

mtdkei commented Jan 31, 2025

@kurudrive
あーそれでした!wp_kses_post()を外したら表示できました。ただ外すわけにはいかないと思うので以下を適用するとかですかね?他にもいい方法がありましたら。
仕様ということで従来のウィジェットを案内するということも考えられますが。


function veu_allow_iframe_in_wp_kses_post( $tags, $context ) {
    if ( $context ) {
        $tags['iframe'] = array(
            'src'             => true,
            'width'           => true,
            'height'          => true,
            'style'           => true,
            'allowfullscreen' => true,
            'loading'         => true,
            'sandbox'         => true,
        );
    }
    return $tags;
}
add_filter( 'wp_kses_allowed_html', 'veu_allow_iframe_in_wp_kses_post', 10, 2 );

@kurudrive
Copy link
Member

@mtdkei マジカヨ.... wp_kses_allowed_html フィルター初めて知ったわ...
まぁでも扱い難しいねぇ...
iframe許可するとそのうち「脆弱性だ」って言ってくる人いるしなぁ...

めっちゃ回りくどいけど iframe が使われてて、参照先が google map など許可対象なら そのフィルターが走るようにして、
他の wp_kses_post() に影響がないように echo したら remove_filter するとか...?

@mtdkei
Copy link
Contributor Author

mtdkei commented Jan 31, 2025

@kurudrive
おっしゃる通り、全てのiframeを許可した時はそのような懸念はありますね。
石川さんご提案のものを試してプルリクを出してみます。ありがとうございます。

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

No branches or pull requests

2 participants