File manager - Edit - /usr/local/cpanel/bin/repair_yaml_file
Back
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - bin/repair_yaml_file Copyright 2022 cPanel, L.L.C. # All rights reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited use strict; use warnings; use YAML::Tiny (); use Cpanel::YAML::Syck (); use Cpanel::SafeFile::RW (); $YAML::Syck::ImplicitTyping = 0; foreach my $file (@ARGV) { Cpanel::SafeFile::RW::safe_readwrite( $file, sub { my ( $rw_fh, $safe_replace_content_coderef ) = @_; local $/; my $old_yaml = readline($rw_fh); if ( !$old_yaml ) { warn "No data was read from $file"; return; } my $old_data = ( YAML::Tiny::Load($old_yaml) )[0]; if ( !$old_data ) { warn "Could not get data struct via YAML::Tiny::Load from $file"; return; } my $new_yaml = YAML::Syck::Dump($old_data); if ( !$new_yaml ) { warn "Could not get YAML via YAML::Syck::Dump from $file\'s old data"; return; } return "Fix YAML via $0" if $safe_replace_content_coderef->( $rw_fh, [$new_yaml] ); warn "Could not write $file"; return; } ); }
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings