Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- run: npm run lint:php
Expand All @@ -35,7 +36,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- run: npm run test:unit:php
Expand All @@ -47,7 +49,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- name: Build distributable zip
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- run: npm run lint:php
Expand All @@ -44,7 +45,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- run: npm run lint:js
Expand All @@ -57,7 +59,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- run: npm run test:unit:php
Expand All @@ -69,7 +72,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- name: Build distributable zip
Expand Down Expand Up @@ -106,7 +110,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- name: Download test zip artifact
Expand Down Expand Up @@ -139,7 +144,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- name: Download test zip artifact
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/release-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm

- run: npm ci
Expand Down Expand Up @@ -244,7 +245,8 @@ jobs:
ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- run: npm run lint:php
Expand All @@ -260,7 +262,8 @@ jobs:
ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- run: npm run test:unit:php
Expand All @@ -279,7 +282,8 @@ jobs:
ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'
check-latest: true
cache: npm
- run: npm ci
- name: Download built artifact
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.4.3

- Updated development and build dependencies to clear security advisories in the toolchain; no change to plugin behaviour
- Building the plugin from source now requires Node.js 24.18 or later (npm 11.16 or later)

## 0.4.2

- Security: Google Fonts used in global styles are now only downloaded from Google's own font servers, and only saved as WOFF2 font files; `http://` and protocol-relative Google Fonts links are upgraded to HTTPS and localised too
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Airo WP is a **plugin scaffold**: bootstrap, DI container, package loader, Strau

| Tool | Version | Notes |
|------|---------|-------|
| Node.js | 20+ | Required |
| npm | 10+ | Required |
| Node.js | 24.18+ | Required (latest 24.x LTS recommended). Node 25 is not supported: `@wordpress/scripts` excludes it (`^24.15.0 \|\| >=26`) |
| npm | 11.16+ | Required (bundled with Node.js 24.18+) |
| Docker | 24+ | Required by the WordPress test environment |
| PHP | 7.4+ | Optional — only needed if running Composer on the host |
| Composer | 2.x | Optional — runs inside the WordPress environment |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
|---|---|
| **Plugin name** | Airo WP AI Builder |
| **Text domain** | `airo-wp` |
| **Version** | 0.4.2 |
| **Version** | 0.4.3 |
| **Requires WordPress** | 6.9+ |
| **Requires PHP** | 7.4+ |
| **License** | [GPLv2 or later](https://www.gnu.org/licenses/gpl-2.0.html) |
Expand Down
4 changes: 2 additions & 2 deletions airo-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Airo WP AI Builder
* Plugin URI: https://github.com/godaddy-wordpress/airo-wp
* Description: MCP server and block pattern library for AI-powered site building.
* Version: 0.4.2
* Version: 0.4.3
* Requires at least: 6.9
* Requires PHP: 7.4
* Author: GoDaddy
Expand Down Expand Up @@ -47,7 +47,7 @@
defined( 'ABSPATH' ) || exit;

if ( ! defined( 'AIRO_WP_VERSION' ) ) {
define( 'AIRO_WP_VERSION', '0.4.2' );
define( 'AIRO_WP_VERSION', '0.4.3' );
}
if ( ! defined( 'AIRO_WP_PLUGIN_FILE' ) ) {
define( 'AIRO_WP_PLUGIN_FILE', __FILE__ );
Expand Down
28 changes: 27 additions & 1 deletion functions/blocks/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ function airowp_normalize_css_escapes( $css ) {
$css = str_replace( "\0", '', $css );

// Unicode escape: backslash + 1..6 hex digits + optional single whitespace.
// "Whitespace" is CSS's, not PCRE's `\s`: CR LF is ONE newline to a browser,
// so it goes as a pair, and vertical tab is not whitespace at all. Eating
// only the CR of `\75\r\nrl(` left `u\nrl(`, which hid a `url(` the browser
// still saw.
$css = preg_replace_callback(
'/\\\\([0-9a-fA-F]{1,6})\s?/',
'/\\\\([0-9a-fA-F]{1,6})(?:\r\n|[ \t\r\n\f])?/',
static function ( $matches ) {
$codepoint = hexdec( $matches[1] );

Expand Down Expand Up @@ -259,6 +263,28 @@ function airowp_is_dsg_block( $block_name ) {
return strpos( $block_name, 'airo-wp/' ) === 0;
}

/**
* Restrict a container block's tagName to the elements it may render as.
*
* Section, Row and Grid store their wrapper element as a free-form `tagName`
* string in the block comment, and any author can write that comment by hand.
* kses never sees it as markup - `img src=x onerror=...` contains no `<` - so
* PHP that builds `'<' . $tag` from it writes a live element into the page.
* Every such place must pass the value through here first.
*
* The list mirrors the "HTML Element" options in each block's edit.js and the
* `enum` on `tagName` in their block.json files; change all three together.
*
* @param mixed $tag Stored tagName value.
* @param string $fallback Element to use when $tag is not allowed.
* @return string An allowed element name, or $fallback.
*/
function airowp_sanitize_container_tag( $tag, $fallback = 'div' ) {
$allowed = array( 'div', 'section', 'article', 'aside', 'header', 'footer', 'main' );

return is_string( $tag ) && in_array( $tag, $allowed, true ) ? $tag : $fallback;
}

/**
* Resolve a WordPress preset color reference to its concrete value.
*
Expand Down
91 changes: 91 additions & 0 deletions includes/Blocks/Common/Forms/FormEmailLabels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* Field labels for the {all_fields} summary in notification emails.
*
* @package airo-wp
* @since 2.11.2
*/

declare(strict_types=1);

namespace GoDaddy\WordPress\Plugins\AiroWp\Blocks\Common\Forms;

defined( 'ABSPATH' ) || exit;
/**
* Form_Email_Labels.
*
* The recipient of a notification never saw the form's markup, so a field is
* named by what the visitor saw, never by its `name` attribute. In order:
*
* 1. The field's label as rendered on the page (placeholder when the label is
* empty — see FormHandler::extract_field_labels_from_blocks()). Labels are
* taken verbatim, so a form authored or translated into another language
* reports in that language.
* 2. A hand-written field name, title-cased (`job_title` → "Job Title").
* 3. "Hidden field" / "Untitled field" when the name was generated by the
* editor (`field_ecbc26c5`, `select-662eef03`): those ids mean nothing to
* the recipient.
*
* A label already used by an earlier field gets " (2)", " (3)", … so two
* "Name" fields stay distinguishable without exposing their ids.
*/
class FormEmailLabels {

/**
* Names the editor generates for a new field: a prefix plus the first 8
* hex characters of the block's clientId (see each form-*-field edit.js).
* The phone field adds a `_country_code` companion.
*/
const GENERATED_NAME = '/^(?:field_|(?:checkbox|date|hidden|number|phone|select|time|url)-)[0-9a-f]{8}(?:_country_code)?$/i';

/**
* Resolve a display label for every submitted field, in submission order.
*
* @param array $fields Sanitized fields keyed by name, each { value, type }.
* @param array<string, string> $labels Visible labels keyed by field name.
* @return array<string, string> Display labels keyed by field name.
*/
public static function resolve( array $fields, array $labels ): array {
$resolved = array();
$seen = array();

foreach ( $fields as $name => $data ) {
$name = (string) $name;
$label = isset( $labels[ $name ] ) ? trim( (string) $labels[ $name ] ) : '';

if ( '' === $label ) {
$type = is_array( $data ) && isset( $data['type'] ) ? (string) $data['type'] : '';
$label = self::fallback( $name, $type );
}

$key = function_exists( 'mb_strtolower' ) ? mb_strtolower( $label, 'UTF-8' ) : strtolower( $label );
$seen[ $key ] = isset( $seen[ $key ] ) ? $seen[ $key ] + 1 : 1;

if ( $seen[ $key ] > 1 ) {
/* translators: 1: field label, 2: occurrence number of that label in the form */
$label = sprintf( __( '%1$s (%2$d)', 'airo-wp' ), $label, $seen[ $key ] );
}

$resolved[ $name ] = $label;
}

return $resolved;
}

/**
* Label for a field with no visible label.
*
* @param string $name Field name.
* @param string $type Server-side field type.
* @return string Readable label.
*/
private static function fallback( $name, $type ) {
if ( '' !== $name && ! preg_match( self::GENERATED_NAME, $name ) ) {
return ucwords( str_replace( array( '_', '-' ), ' ', $name ) );
}

return 'hidden' === $type
? __( 'Hidden field', 'airo-wp' )
: __( 'Untitled field', 'airo-wp' );
}
}
26 changes: 21 additions & 5 deletions includes/Blocks/Common/Forms/FormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,13 @@ function ( $value, $type ) {
}

// Send email notification if enabled (settings looked up server-side from block attributes).
$this->send_email_notification( $form_id, $sanitized_fields, $submission_id, $block_attrs );
$this->send_email_notification(
$form_id,
$sanitized_fields,
$submission_id,
$block_attrs,
isset( $form_definition['labels'] ) ? $form_definition['labels'] : array()
);

// Trigger action hook for email notifications, integrations, etc.
// The fourth argument is the form's server-resolved block attributes.
Expand Down Expand Up @@ -1173,8 +1179,10 @@ private static function flatten_value( $value ) {
* @param array|null $block_attrs Attributes of the form the submission was
* validated against. Passing them keeps the
* email on the same copy of a shared form ID.
* @param array $labels Visible field labels keyed by name, from
* the same form definition.
*/
private function send_email_notification( $form_id, $fields, $submission_id, $block_attrs = null ) {
private function send_email_notification( $form_id, $fields, $submission_id, $block_attrs = null, array $labels = array() ) {
// Look up email settings from the form block attributes (server-side only).
// This prevents client-side manipulation of email configuration.
if ( null === $block_attrs ) {
Expand Down Expand Up @@ -1306,12 +1314,14 @@ private function send_email_notification( $form_id, $fields, $submission_id, $bl

// The {all_fields} summary is markup by construction, so it is built once
// per context rather than escaped generically: HTML for the body, and a
// flat one-liner for the subject (where tags would be nonsense).
// flat one-liner for the subject (where tags would be nonsense). Each row
// is named by the label the visitor saw, never the generated field name.
$display_labels = Form_Email_Labels::resolve( $fields, $labels );
$all_fields_html = '';
$all_fields_text = array();
foreach ( $fields as $field_name => $field_data ) {
$value = self::stringify_field_value( $field_data );
$label = ucwords( str_replace( array( '_', '-' ), ' ', $field_name ) );
$label = $display_labels[ (string) $field_name ];

$all_fields_html .= sprintf( "<strong>%s:</strong> %s<br>\n", esc_html( $label ), esc_html( $value ) );
$all_fields_text[] = $label . ': ' . $value;
Expand Down Expand Up @@ -2008,7 +2018,9 @@ private function extract_field_types_from_blocks( $blocks ) {
* Extract each field's visible label from a form's inner blocks.
*
* A label left at its block.json default is absent from the block comment,
* so the registered default is used. Labels are stored as plain text.
* so the registered default is used. A label cleared to nothing falls back
* to the placeholder, the only text the visitor then sees for the field.
* Labels are stored as plain text.
*
* @param array $blocks Parsed inner blocks.
* @return array<string, string> Labels keyed by field name.
Expand All @@ -2025,6 +2037,10 @@ private function extract_field_labels_from_blocks( $blocks ) {
$label = isset( $attrs['label'] ) && is_string( $attrs['label'] ) ? $attrs['label'] : $this->default_field_label( $block_name );
$label = trim( html_entity_decode( wp_strip_all_tags( $label ), ENT_QUOTES, 'UTF-8' ) );

if ( '' === $label && isset( $attrs['placeholder'] ) && is_string( $attrs['placeholder'] ) ) {
$label = trim( html_entity_decode( wp_strip_all_tags( $attrs['placeholder'] ), ENT_QUOTES, 'UTF-8' ) );
}

if ( '' !== $label ) {
$labels[ $field_name ] = $label;
}
Expand Down
Loading
Loading