AxGryndr
AxGryndr

Reputation: 2344

URL query string has a comma in the string

I am having an issue with a URL query string and I believe the issue is that my parameter sometimes has a comma in it.

What happens is I have a query string that is generated from a list of group names so that my string looks something like:

 Group=GroupName1,GroupName2,GroupName3

While doing some testing I noticed that some of my groups are not being displayed on the page even though they are in the query string. Then I noticed that the groups that are not showing are those that have a comma in the name. For example:

 Group=People,%20Places%20and%20Stuff

Obviously the query string gets parsed looking for 'People' as a group and 'Places and Stuff' as a group. This is an issue because the group is 'People, Places and Stuff'. I don't have any control over the group names so they cannot be changed to not include commas. I tried to encode the comma in the string using %2C however that had no impact.

I did some searching but I couldn't find anything other than a suggestion about changing the server so that the delimiter isn't a comma but I don't have the ability to that. Any other solution or am I stuck?

Upvotes: 19

Views: 24466

Answers (1)

AxGryndr
AxGryndr

Reputation: 2344

After doing a bunch of hunting I finally found the answer.

I was on the right track encoding the comma as %2C however this has to be preceded by an escape character of %5C. Therefore the url query string would be the following:

 Group=People%5C%2C%20Places%20and%20Stuff

Upvotes: 22

Related Questions