diff options
author | Simon Rettberg | 2022-10-27 17:23:16 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-10-27 17:23:16 +0200 |
commit | 62b6d7560f36b538f216074af90f41fc0f98b0ce (patch) | |
tree | 85b79003a54df26a34264bc01e4b10a2e5dceb95 /modules-available/serversetup-bwlp-ipxe | |
parent | [statistics] Add machine state icon to hints tables (diff) | |
download | slx-admin-62b6d7560f36b538f216074af90f41fc0f98b0ce.tar.gz slx-admin-62b6d7560f36b538f216074af90f41fc0f98b0ce.tar.xz slx-admin-62b6d7560f36b538f216074af90f41fc0f98b0ce.zip |
[serversetup-bwlp-ipxe] Encode ipxe script depending on iPXE version
Newer iPXE versions require UTF-8
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe')
-rw-r--r-- | modules-available/serversetup-bwlp-ipxe/inc/ipxebuilder.inc.php | 2 | ||||
-rw-r--r-- | modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php | 24 |
2 files changed, 19 insertions, 7 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/inc/ipxebuilder.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/ipxebuilder.inc.php index d6633f67..3a82b4f7 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/ipxebuilder.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/ipxebuilder.inc.php @@ -63,12 +63,14 @@ class IPxeBuilder if (isset($list['versions'])) { foreach ($list['versions'] as $v) { if ($v['hash'] === $version) { + // Do NOT change (see below) $version = date('Y-m-d H:i', $v['date']) . ' (' . substr($version, 0, 7) . ')'; break; } } } } + // Do NOT change the format of this string -- we depend on it in ScriptBuilderIpxe::output() $buildString = date('d.m.Y H:i') . ', Version: ' . $version; Property::set(IPxeBuilder::PROP_IPXE_BUILDSTRING, $buildString); } diff --git a/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php index 59c1bb7c..9165b293 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php @@ -323,15 +323,25 @@ BLA; public function output($string) { - setlocale(LC_ALL, 'de_DE.UTF-8', 'de_DE.utf-8', 'de_DE.utf8', 'de_DE', 'de', 'German', 'ge', 'en_US.UTF-8', 'en_US.utf-8'); - if ($this->platform === 'EFI') { - $cs = 'ASCII'; + // iPXE introduced UTF-8 support at some point in 2022, and now expects all text/script files to be + // encoded as such. Since we still offer to use older versions, we need to detect that here and handle + // all non-ASCII chars differently. + // Use 'ipxe.compile-time' instead of const from IpxeBuilder to avoid pulling in another include + if (!preg_match('/Version: (\d{4})-\d{2}-\d{2}\b/', Property::get('ipxe.compile-time'), $out) + || (int)$out[1] >= 2022) { + Header('Content-Type: text/plain; charset=UTF-8'); + echo $string; } else { - $cs = 'IBM437'; - } - Header('Content-Type: text/plain; charset=' . $cs); + if ($this->platform === 'EFI') { + $cs = 'ASCII'; + } else { + $cs = 'IBM437'; + } + Header('Content-Type: text/plain; charset=' . $cs); - echo iconv('UTF-8', $cs . '//TRANSLIT//IGNORE', $string); + setlocale(LC_ALL, 'de_DE.UTF-8', 'de_DE.utf-8', 'de_DE.utf8', 'de_DE', 'de', 'German', 'ge', 'en_US.UTF-8', 'en_US.utf-8'); + echo iconv('UTF-8', $cs . '//TRANSLIT//IGNORE', $string); + } } public function modfilt($str) |