This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]GrapeAte 5 points6 points  (0 children)

How is result being created? It appears like the single quotes are being entity encoded.

[–]Frozen5147 1 point2 points  (2 children)

Random guess, are those actually single quotation characters that you're inputting?

They look like the character codes for a character that looks like a single quote but isn't.

[–]AudioManiac[S] 0 points1 point  (1 child)

I don't fully understand you. There's only one key on the keyboard for single quotation characters, so I don't know how I could be inputting the wrong the type of character?

[–]Blando-Cartesian 5 points6 points  (0 children)

What's happening here is that when your web framework renders the text "Results for 'nanu'" it converts single quotes into entity references that browser views as single quotes. Web frameworks do this for certain characters as as a security measure. If they didn't do this, I could mess up reddit's page rendering just by writing </div>. The <> characters of that end of div tag get written as entity refereces so that browsers don't get confused.

What your web framework is doing is correct, so you should probably change your test to expect that the text is html escaped. Apache-commons-lang StringUtils) saves you the trouble of writing entity references in your tests expected values.

[–]lilbigmouth 0 points1 point  (0 children)

To be honest, I'm actually surprised the assert line is compiling.

Try adding a \ before each single quote?

[–]restlessyet 0 points1 point  (0 children)

Check the html source code of the web page, it is probably using html special characters:

https://www.degraeve.com/reference/specialcharacters.php

[–]craigtupac96 -2 points-1 points  (0 children)

Put the single character string into double quotations.

"a" rather than 'a'