Skip to content

ext/curl: Fix sync-constants script #13209

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

Merged
merged 1 commit into from
Jan 21, 2024
Merged
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
12 changes: 6 additions & 6 deletions ext/curl/sync-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function getCurlConstants() : array
$html = file_get_contents(CURL_DOC_FILE);

// Extract the constant list from the HTML file (located in the only <pre> tag in the page)
preg_match('~<pre>([^<]+)</pre>~', $html, $matches);
preg_match('~<table>(.*?)</table>~s', $html, $matches);
$constantList = $matches[1];

/**
Expand All @@ -220,16 +220,16 @@ function getCurlConstants() : array
* CURLOPT_FTPASCII 7.1 7.11.1 7.15.5
* CURLOPT_HTTPREQUEST 7.1 - 7.15.5
*/
$regexp = '/^([A-Za-z0-9_]+) +([0-9\.]+)(?: +([0-9\.\-]+))?(?: +([0-9\.]+))?/m';
$regexp = '@<tr><td>(?:<a href=".*?">)?(?<const>[A-Za-z0-9_]+)(?:</a>)?</td><td>(?:<a href=".*?">)?(?<added>[\d\.]+)(?:</a>)?</td><td>(?:<a href=".*?">)?(?<deprecated>[\d\.]+)?(?:</a>)?</td><td>(<a href=".*?">)?(?<removed>[\d\.]+)?(</a>)?</td></tr>@m';
preg_match_all($regexp, $constantList, $matches, PREG_SET_ORDER);

$constants = [];

foreach ($matches as $match) {
$name = $match[1];
$introduced = $match[2];
$deprecated = $match[3] ?? null;
$removed = $match[4] ?? null;
$name = $match['const'];
$introduced = $match['added'];
$deprecated = $match['deprecated'] ?? null;
$removed = $match['removed'] ?? null;

if (in_array($name, IGNORED_CURL_CONSTANTS, true) || !preg_match(CONSTANTS_REGEX_PATTERN, $name)) {
// not a wanted constant
Expand Down