Expand my Community achievements bar.

SOLVED

html in href in text comp is encoded

Avatar

Level 1

If you try to save a value like this for the href :

 

http://...emailAddress=<span class=email>EmailAddress</span>&URL=https://../global/en/home/library/measurements.html

 

It is replaced with encoded chars for the < and > in the <span> tag. e.g. it becomes

 

http://...emailAddress=%3Cspan%20class=email%3EEmailAddress%3C/span%3E&URL=https://../global/en/home/library/measurements.html

 

after you save the component, reload the page, and go back to edit again.

It should allow the < and > tags

 

characters such as less-than (<), greater-than (>)  get encoded, but should not be

 

AEM 6.4.7 instance

 

Capture.PNG

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi @shivakumark6662,

I don't really understand the problem. It is totally normal for the href attribute to be encoded, as it should be. This is because URLs must be encoded to function to function correctly.

Even if you could have an un-encoded href, any modern browser will just encode the URL before making a request. Take a look at this example:

Theo_Pendle_0-1590594573992.png

As you can see, even though I tried to access a URL with un-encoded XML characters, Chrome made a request using their encoded equivalents. With that in mind, there would be no point in creating a "fix" to allow un-encoded href attributes, because they would just be overriden by your browser.

Just to further illustrate the point, we can try the same request via curl:

$ curl http:localhost:8081?xml=<span></span>
bash: syntax error near unexpected token `<'

As you can see we get an error since unlike Chrome, curl doesn't automatically encode the URL.

Can you explain why you want un-encoded href attributes? 

 

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi @shivakumark6662,

I don't really understand the problem. It is totally normal for the href attribute to be encoded, as it should be. This is because URLs must be encoded to function to function correctly.

Even if you could have an un-encoded href, any modern browser will just encode the URL before making a request. Take a look at this example:

Theo_Pendle_0-1590594573992.png

As you can see, even though I tried to access a URL with un-encoded XML characters, Chrome made a request using their encoded equivalents. With that in mind, there would be no point in creating a "fix" to allow un-encoded href attributes, because they would just be overriden by your browser.

Just to further illustrate the point, we can try the same request via curl:

$ curl http:localhost:8081?xml=<span></span>
bash: syntax error near unexpected token `<'

As you can see we get an error since unlike Chrome, curl doesn't automatically encode the URL.

Can you explain why you want un-encoded href attributes?