From 867bb01a76500482abcea69d6930e8086d7650af Mon Sep 17 00:00:00 2001
From: Gregory Schoppe <gschoppe@gmail.com>
Date: Sun, 12 Nov 2017 00:32:38 -0500
Subject: [PATCH 1/2] add support for single line headers to get_file_data()
---
src/wp-includes/functions.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index b5d21285b6..59215e2510 100644
a
|
b
|
function get_file_data( $file, $default_headers, $context = '' ) { |
4858 | 4858 | } |
4859 | 4859 | |
4860 | 4860 | foreach ( $all_headers as $field => $regex ) { |
4861 | | if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) |
| 4861 | /* ^(?:\s*<\?(?:php)?\s*)?[ \t\/*#@]*Template Name:([^\/*?]*)(?:\*\/)?\s*(?:\?>)?\s*$ */ |
| 4862 | $rexex = '\s*(?:<\?(?:php)?)?\s*'; // optional opening php tag (long or short) |
| 4863 | $regex .= '[ \t\/*#@]*'; // optional comments, tabs or @ symbols |
| 4864 | $regex .= preg_quote( $regex, '/' ) . ':'; // the header we are searching for |
| 4865 | $regex .= '([^\/*?]*)'; // capture group for header names |
| 4866 | $regex .= '\s*(?:\*\/)?'; // optional end of multiline comment |
| 4867 | $regex .= '\s*(?:\?>)?\s*'; //optional closing php tag, long or short |
| 4868 | if ( preg_match( '/^' . $regex . '$/mi', $file_data, $match ) && $match[1] ) |
4862 | 4869 | $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); |
4863 | 4870 | else |
4864 | 4871 | $all_headers[ $field ] = ''; |
--
2.12.0.windows.1
From ea0cfa80861d15dcd9439d05f1f9c54b6e95c217 Mon Sep 17 00:00:00 2001
From: Gregory Schoppe <gschoppe@gmail.com>
Date: Sun, 12 Nov 2017 08:04:02 -0500
Subject: [PATCH 2/2] fix regex
---
src/wp-includes/functions.php | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 59215e2510..0f4be879f6 100644
a
|
b
|
function get_file_data( $file, $default_headers, $context = '' ) { |
4858 | 4858 | } |
4859 | 4859 | |
4860 | 4860 | foreach ( $all_headers as $field => $regex ) { |
4861 | | /* ^(?:\s*<\?(?:php)?\s*)?[ \t\/*#@]*Template Name:([^\/*?]*)(?:\*\/)?\s*(?:\?>)?\s*$ */ |
4862 | | $rexex = '\s*(?:<\?(?:php)?)?\s*'; // optional opening php tag (long or short) |
4863 | | $regex .= '[ \t\/*#@]*'; // optional comments, tabs or @ symbols |
4864 | | $regex .= preg_quote( $regex, '/' ) . ':'; // the header we are searching for |
4865 | | $regex .= '([^\/*?]*)'; // capture group for header names |
4866 | | $regex .= '\s*(?:\*\/)?'; // optional end of multiline comment |
4867 | | $regex .= '\s*(?:\?>)?\s*'; //optional closing php tag, long or short |
4868 | | if ( preg_match( '/^' . $regex . '$/mi', $file_data, $match ) && $match[1] ) |
| 4861 | $pattern = '[ \t]*(?:<\?(?:php)?)?[ \t]*'; // optional opening php tag (long or short) |
| 4862 | $pattern .= '[ \t\/*#@]*'; // optional comments, tabs or @ symbols |
| 4863 | $pattern .= preg_quote( $regex, '/' ); // the header we are searching for |
| 4864 | $pattern .= '[ \t]*:[ \t]*'; // our colon, wrapped in optional whitespace |
| 4865 | $pattern .= '(.*?)'; // capture group for header names (non-greedy) |
| 4866 | $pattern .= '[ \t]*(?:\*\/)?'; // optional end of multiline comment |
| 4867 | $pattern .= '[ \t]*(?:\?>)?[ \t]*'; //optional closing php tag, long or short |
| 4868 | if ( preg_match( '/^' . $pattern . '$/mi', $file_data, $match ) && $match[1] ) |
4869 | 4869 | $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); |
4870 | 4870 | else |
4871 | 4871 | $all_headers[ $field ] = ''; |