From 0b59be62b674de32ffb7cfadd52054b183a9a382 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Tue, 27 Dec 2022 11:41:59 +0100 Subject: [PATCH] Skip loading/migrating items with invalid name (#14054) Fixes #14053 Signed-off-by: Jacob Laursen --- .../openhab/persistence/jdbc/internal/JdbcMapper.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcMapper.java b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcMapper.java index 7a510527fa394..2b31c759ca434 100644 --- a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcMapper.java +++ b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcMapper.java @@ -27,6 +27,7 @@ import org.knowm.yank.Yank; import org.openhab.core.i18n.TimeZoneProvider; import org.openhab.core.items.Item; +import org.openhab.core.items.ItemUtil; import org.openhab.core.persistence.FilterCriteria; import org.openhab.core.persistence.HistoricItem; import org.openhab.core.persistence.PersistenceItemInfo; @@ -340,6 +341,11 @@ public void populateItemNameToTableNameMap() throws JdbcSQLException { } } else { for (ItemsVO vo : getItemIDTableNames()) { + String itemName = vo.getItemName(); + if (!ItemUtil.isValidItemName(itemName)) { + logger.warn("Skipping invalid item name {}", itemName); + continue; + } itemNameToTableNameMap.put(vo.getItemName(), namingStrategy.getTableName(vo.getItemId(), vo.getItemName())); } @@ -429,6 +435,10 @@ private void formatTableNames() throws JdbcSQLException { } oldNewTableNames = new ArrayList<>(); for (String itemName : itemTables) { + if (!ItemUtil.isValidItemName(itemName)) { + logger.warn("JDBC::formatTableNames: Skipping invalid item name {}", itemName); + continue; + } ItemsVO isvo = new ItemsVO(); isvo.setItemName(itemName); isvo.setItemsManageTable(conf.getItemsManageTable());