contentviews: fix protobuf number encoding#255
Merged
mhils merged 2 commits intomitmproxy:mainfrom Apr 29, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes Protobuf number encoding in contentviews by improving YAML prettification and re-encoding logic to properly handle and represent various numeric types (including signed numbers via ZigZag encoding).
- Introduces a helper struct (NumReprs) to collect multiple numeric representations and select the best one for output.
- Adds a new static tag ZIGZAG for signed integer (sint) handling and updates tests accordingly.
- Refactors re-encoding functions to better convert numeric values for FIXED32, FIXED64, and varint fields.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| mitmproxy-contentviews/src/protobuf/yaml_to_pretty.rs | Implements NumReprs for formatted number representation and comments. |
| mitmproxy-contentviews/src/protobuf/view_protobuf.rs | Adds new ZIGZAG tag and updates tests to reflect new output formats. |
| mitmproxy-contentviews/src/protobuf/view_grpc.rs | Adjusts test expectations for gRPC YAML output. |
| mitmproxy-contentviews/src/protobuf/reencode.rs | Refactors numeric parsing and conversion, including ZigZag encoding. |
| mitmproxy-contentviews/src/protobuf/proto_to_yaml.rs | Modifies tag_number to conditionally tag unknown fields by type. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.