Skip to content

compiler/protogen: sanitize explicit Go package name from go_package - #71

Closed
hibrian827 wants to merge 1 commit into
protocolbuffers:masterfrom
hibrian827:fix/protogen-sanitize-go-package-name
Closed

hibrian827 wants to merge 1 commit into
protocolbuffers:masterfrom
hibrian827:fix/protogen-sanitize-go-package-name

Conversation

@hibrian827

Copy link
Copy Markdown

The Go package name given after the ';' delimiter in a go_package option (or an M=; mapping) was used verbatim as the generated file's package name. A value that is not a valid Go identifier propagated unchecked into generated source.

Validate the explicit package name and fall back to cleanPackageName (strs.GoSanitized) when it is not a valid identifier, matching how package names derived from other sources are already sanitized.

This is from the report I filed to google issue tracker(#547001203)

The Go package name given after the ';' delimiter in a go_package option
(or an M<file>=<importpath>;<name> mapping) was used verbatim as the
generated file's package name. A value that is not a valid Go identifier
propagated unchecked into generated source.

Validate the explicit package name and fall back to cleanPackageName
(strs.GoSanitized) when it is not a valid identifier, matching how
package names derived from other sources are already sanitized.
@google-cla

google-cla Bot commented Aug 16, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@puellanivis puellanivis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your interest into contributing to this project.

Unfortunately this project does not accept GitHub pull requests as the source-of-truth for this project is hosted at https://go.googlesource.com/protobuf. This project page on GitHub is a mirror of that other repository.

If you would like to contribute to this project, please follow the contribution guidelines for instructions on how to send a change. If the change you'd like to make is more substantial or introduces any new features, then it should first be discussed on the issue tracker.

@hibrian827

Copy link
Copy Markdown
Author

Sorry, my bad. I will close this one right away.

@hibrian827 hibrian827 closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants