From 91952955168cab10f3a4ef9eca3644d750435e71 Mon Sep 17 00:00:00 2001 From: Tony Le Date: Tue, 14 Feb 2023 07:44:17 -0800 Subject: [PATCH] Make packet layer names case-insensitive for backward compatibility with v0.4.6 --- src/pyshark/packet/packet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyshark/packet/packet.py b/src/pyshark/packet/packet.py index e4244bc..627a196 100644 --- a/src/pyshark/packet/packet.py +++ b/src/pyshark/packet/packet.py @@ -47,7 +47,7 @@ def __getitem__(self, item): if isinstance(item, int): return self.layers[item] for layer in self.layers: - if layer.layer_name == item.lower(): + if layer.layer_name.lower() == item.lower(): return layer raise KeyError('Layer does not exist in packet') @@ -120,7 +120,7 @@ def __getattr__(self, item): Allows layers to be retrieved via get attr. For instance: pkt.ip """ for layer in self.layers: - if layer.layer_name == item: + if layer.layer_name.lower() == item.lower(): return layer raise AttributeError(f"No attribute named {item}")