Making WordPress.org

Changeset 10685


Ignore:
Timestamp:
02/17/2021 04:21:33 AM (4 years ago)
Author:
dd32
Message:

Translate: Automatically correct strings which contain extra spaces within HTML tags.

This fixes strings such as </ p>, <a href="%s" >, and < / strong >. <a href="#" >
This does not affect spaces between attributes, such as <a href="#" target="_blank"> due to the limited cases recorded of that being an issue.

See #5154.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-fixer/wporg-gp-translation-fixer.php

    r10684 r10685  
    9898                        );
    9999
     100                        // Try correcting HTML tags containing extra spaces, eg </ p>, <a href="#" >, < / p>, relies upon the original having well-formed HTML.
     101                        $translation = preg_replace(
     102                            // Opening HTML element, Tag Name, Attributes (zero or more), Closing HTML element
     103                            '!<\s*(/)?\s*' . '([a-z]+)\s*' . '(\s+[a-z]+=["\'][^>]+["\'])*' . '\s*>!i',
     104                            '<$1$2$3>', // 1: Closing slash, 2: Tag, 3: Attributes
     105                            $translation
     106                        );
     107
    100108                        break;
    101109                }
Note: See TracChangeset for help on using the changeset viewer.