{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Developer Portal (Drupal-based) /
avatar image
1
Question by DSX-Team · Nov 16, 2015 at 11:41 AM · 15.9k Views dynamic target endpointrequest param

How to handle Query params with special characters

Hi folks,

I want to pass the comma separated query paramerters to the target endpoint url, hence i have tried to do it with below mentioned 2 ways.

1. In Proxy Endpoints Preflow, Tried to get the params from the request url and set the Query params via Assign Message policy in order to pass it as a query params to the target endpoint url

2. In Target Endpoints Preflow, Tried to get the params from the request url inside javascript and made a new target url there by embedding comma separated query params to the target endpoint url and further assigning it to the 'target.url' apigee variable.

I'm yet unable to hit the target url properly because while apigee hits this new target url, it replaces query param commas with %2C

eg. https://hostname:port/basepath?q=q1,q2,q3

getting converted to

https://hostname:port/basepath?q=q1%2Cq2%2Cq3

Because of the above change not getting the desired response as backend is not able to resolve %2C%2C.

Can anyone pl help here?

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

1 Answer

  • Sort: 
avatar image
2

Answer by Dino   · Nov 24, 2015 at 02:37 AM

Unfortunately it seems you are running into a particularly grey area in the W3 specifications.

The spec for form submission states that, for GET requests, all data is encoded using the "application/x-www-form-urlencoded" content type. And further, that means:

Control names and values are escaped. Space characters are replaced by `+', and then [1] reserved characters are escaped as described in [RFC1738], section 2.2: [2] Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').

That paragraph provides all the grey fuzzies you need to get into trouble. The sentence marked [1] above says that "reserved characters are escaped as described in RFC1738". And the sentence marked [2] above says "non-alphanumeric characters are replaced by %HH".

Considering the above, Should the comma, when part of the value of a query param, be encoded as %2C or not? Not clear. In the first place, the comma is not "reserved", and the first sentence above suggests that it need not be encoded. In the second place, the comma is non-alphanumeric, and the 2nd sentence seems to require that it be encoded. Fuzz!

Where are we to turn when the rules are fuzzy? The next best thing is de-facto standards.

The default behavior of modern browsers such as Chrome and Firefox is to encode commas when they appear in values of query params. Likewise the behavior of the Javascript built-in function, encodeURIComponent(), which is used in jQuery and other browser-side ajax frameworks.

The behavior of Apigee Edge is to do the same.

One might argue, "it's not necessary to encode commas!" But one would be arguing with a very large portion of the internet.

The safest thing, then, is to call decodeURIComponent() or the equivalent, on all received query strings, within your server.

In other words, your backend needs to tolerate encoded commas when they appear in the values of query params.

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Articles
  • Ideas
  • Badges