Skip to content

Commit 4755574

Browse files
committed
Fix non-utf prefix for device fields
1 parent 383acba commit 4755574

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

LibreNMS/Modules/Os.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ private function handleChanges(\LibreNMS\OS $os): void
153153
Log::info(trans('device.attributes.location') . ': ' . $device->location?->display());
154154
foreach (['hardware', 'version', 'features', 'serial'] as $attribute) {
155155
if (isset($device->$attribute)) {
156-
$device->$attribute = trim($device->$attribute);
156+
$device->$attribute = preg_replace('/^[\x00-\x1F\x7F-\xFF ]+/', '', $device->$attribute);
157+
}
158+
if ($device->isDirty($attribute)) {
159+
Log::info(DeviceObserver::attributeChangedMessage($attribute, $device->$attribute, $device->getOriginal($attribute)));
157160
}
158-
Log::info(DeviceObserver::attributeChangedMessage($attribute, $device->$attribute, $device->getOriginal($attribute)));
159161
}
160162

161163
$device->save();

0 commit comments

Comments
 (0)