Skip to content

AdafruitIO_Group: compare feed names case-insensitively #124

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

Closed
wants to merge 1 commit into from

Conversation

phord
Copy link
Contributor

@phord phord commented Jun 6, 2020

Feeds are matched with a case-sensitive search when adding new feed
data to a Group. This can cause different values to be published
for the same feed in a single call to save() in a way that's not
easy to see from the code.

Avoid the problem by matching feeds case-insensitively when searching
for existing feeds in the Group data list.

Note: I added the new strcmp_nocase function inline in the
AdafruitIO_Group.cpp module since I didn't see any clear place to put
these kinds of utility functions in the library. I'm open to moving
it, renaming, restructuring it or whatever. Perhaps a better option
is to use the String::equalsIgnoreCase(), but constructing String
temporaries for each comparison seemed excessive to me.

Fixes #123

@phord phord marked this pull request as draft June 6, 2020 22:54
Feeds are matched with a case-sensitive search when adding new feed
data to a Group.  This can cause different values to be published
for the same feed in a single call to save() in a way that's not
easy to see from the code.

Also, subscribing to a feed using the uppercase name of the feed
will never work since the feed names are lowercased when received
from AdafruitIO but the string compare here is strictly
case-sensitive.

Fix these problems by matching feed names case-insensitively when
searching for existing feeds in the Group data list and when matching
callback lookups.

Note: I added the new `strsame_nocase` function inline in the
AdafruitIO_Group.cpp module since I didn't see any clear place to put
these kinds of utility functions in the library.  I'm open to moving
it, renaming, restructuring it or whatever.  Perhaps a better option
is to use the `String::equalsIgnoreCase()`, but constructing String
temporaries for each comparison seemed excessive to me.

Fixes adafruit#123
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.

Feed names' case-sensitive during publish
1 participant