Skip to content

Commit

Permalink
Merge pull request #1382 from Automattic/fix/cors-requests
Browse files Browse the repository at this point in the history
Fix handling responses to form submissions from an AMP Cache
  • Loading branch information
westonruter authored Aug 30, 2018
2 parents 853f7fb + d73ab0d commit 64cad60
Show file tree
Hide file tree
Showing 11 changed files with 982 additions and 747 deletions.
4 changes: 4 additions & 0 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ function amp_init() {

add_rewrite_endpoint( amp_get_slug(), EP_PERMALINK );

add_filter( 'allowed_redirect_hosts', array( 'AMP_HTTP', 'filter_allowed_redirect_hosts' ) );
AMP_HTTP::purge_amp_query_vars();
AMP_HTTP::send_cors_headers();
AMP_HTTP::handle_xhr_request();
AMP_Theme_Support::init();
AMP_Validation_Manager::init();
AMP_Post_Type_Support::add_post_type_support();
Expand Down
14 changes: 14 additions & 0 deletions includes/amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -888,3 +888,17 @@ function amp_print_schemaorg_metadata() {
<script type="application/ld+json"><?php echo wp_json_encode( $metadata ); ?></script>
<?php
}

/**
* Filters content and keeps only allowable HTML elements by amp-mustache.
*
* @see wp_kses()
* @since 1.0
*
* @param string $markup Markup to sanitize.
* @return string HTML markup with tags allowed by amp-mustache.
*/
function amp_wp_kses_mustache( $markup ) {
$amp_mustache_allowed_html_tags = array( 'strong', 'b', 'em', 'i', 'u', 's', 'small', 'mark', 'del', 'ins', 'sup', 'sub' );
return wp_kses( $markup, array_fill_keys( $amp_mustache_allowed_html_tags, array() ) );
}
2 changes: 1 addition & 1 deletion includes/class-amp-autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AMP_Autoloader {
private static $_classmap = array(
'AMP_Editor_Blocks' => 'includes/admin/class-amp-editor-blocks',
'AMP_Theme_Support' => 'includes/class-amp-theme-support',
'AMP_Response_Headers' => 'includes/class-amp-response-headers',
'AMP_HTTP' => 'includes/class-amp-http',
'AMP_Comment_Walker' => 'includes/class-amp-comment-walker',
'AMP_Template_Customizer' => 'includes/admin/class-amp-customizer',
'AMP_Post_Meta_Box' => 'includes/admin/class-amp-post-meta-box',
Expand Down
Loading

0 comments on commit 64cad60

Please sign in to comment.