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

outputs/warp10: url encode comma in tags value #8657

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

BlackYoup
Copy link
Contributor

@BlackYoup BlackYoup commented Jan 6, 2021

Hello,

The warp10 specification requires the commas in tag values to be URL encoded as %2C. This PR fixes this behavior.

I'm not very familiar with Golang, let me know if there is anything I should do better.

EDIT: Without this, Warp10 will reject the input and reply a parse error. This is the case with the current Elasticsearch input plugin for example.

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

Copy link
Contributor

@ivorybilled ivorybilled left a comment

Choose a reason for hiding this comment

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

Makes sense to me

@sjwang90 sjwang90 added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jan 12, 2021
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@srebhan srebhan self-assigned this Jan 20, 2021
@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jan 20, 2021
Comment on lines 177 to 178
value := strings.Replace(tag.Value, ",", "%2C", -1)
tagsString[index] = fmt.Sprintf("%s=%s", tag.Key, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about query escaping this with the same function used for URL encoding, so all special characters are handled? you could do this for the tag key as well.

Suggested change
value := strings.Replace(tag.Value, ",", "%2C", -1)
tagsString[index] = fmt.Sprintf("%s=%s", tag.Key, value)
value := url.QueryEscape(tag.Value)
tagsString[index] = fmt.Sprintf("%s=%s", tag.Key, value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mh, it might be better indeed. After looking again at the Warp10 specification, it seems that both tag key and value should be url encoded, I just didn't encounter an issue with it. But at the same time, most of the characters would be fine, only ,, { and } would be a real issue.

I think I'll adapt your commit to url encode the key too, would that be okay? Or I can commit your changes if you prefer to do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess both is fine for @ssoroka. Will remove the "ready-to-merge" label and wait for your changes... :-) Thanks for taking care of this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'll make the changes withing a few days, thanks :)

@srebhan srebhan removed the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jan 27, 2021
@BlackYoup
Copy link
Contributor Author

I rebased this branch onto master and I amended the commit to also url encode the tag key. Let me know if there is anything else I should do.

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

LGTM.

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Feb 9, 2021
@ivorybilled ivorybilled merged commit f09e551 into influxdata:master Feb 16, 2021
ssoroka pushed a commit that referenced this pull request Feb 17, 2021
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants