pubnub / dart

PubNub Dart SDK
Other
28 stars 15 forks source link

Meta encoding problem #25

Closed vikmind closed 3 years ago

vikmind commented 3 years ago

Building our chat app, I found interesting bug: spaces in usernames in messages sent from flutter client appear as plus signs. But when the same messages were loaded from history, usernames showed normally.

Screenshot

Here is the demo https://github.com/vikmind/pubnub_meta_demo (I used fork from https://github.com/pubnub/dart/pull/24 in the demo to load history with meta and to show the difference. The issue with messages from subscription does not depend on it)

Looks like the problem lies in the encoding differences when sending message to PubNub REST API, meta info goes into query part of the URI and dart client is encoding it according to spec.

I assume that transmitting server is interpreting it as URI component, where encoding is slightly different. My assumption is confirmed by the fact that JS SDK use encodeURIComponent for building query component. That's why such problem does not exist there.

So basically, dart sdk uses correct but different (from server and js sdk) encoding when sending additional parameters to REST API. And I am not sure where it should be patched 🤷

are commented 3 years ago

Thanks for reporting this issue!

It definitely looks like this was overlooked at some point. I'll take a look and figure out the fix for this.

are commented 3 years ago

This should be resolved in the latest version 3.1.0. Let us know if the problem persists!