Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make packet layer names case-insensitive for backward compatibility with v0.4.6 #638

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pyshark/packet/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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}")

Expand Down