kotlinx.html
kotlinx.html copied to clipboard
Issue with amp for get request parameters
kotlinx.html adds amp and browser is not able to process invalid url
https://test.html?name1=value1&name2=value2 -> https://test.html?name1=value1&name2=value2
import kotlinx.html.a
import kotlinx.html.body
import kotlinx.html.html
import kotlinx.html.stream.appendHTML
import org.amshove.kluent.should contain
import org.amshove.kluent.should not contain
import org.junit.jupiter.api.Test
class HtmlTests {
@Test
fun `when a(a&b) then a href=a&b`() {
val getUrl = "https://test.html?name1=value1&name2=value2"
val a = StringBuilder().apply {
appendHTML().html {
body {
a(getUrl)
}
}
}
println(a)
a.`should not contain`("&")
a.`should contain`(getUrl)
}
}
Related to: https://github.com/Kotlin/kotlinx.html/issues/94
I also ran into this with:
link("http://asdf.com/?foo=bar&asdf=zxcv")
Which becomes:
<link href="http://asdf.com/?foo=bar&asdf=zxcv"/>
Why do you expect it to NOT be HTML escaped ?
Because it shouldn't be :)
Web applications frameworks (in my case Vaadin) parse correctly parameters in links like http://asdf.com/?foo=bar&asdf=zxcv and do not process with amp http://asdf.com/?foo=bar&asdf=zxcv"
@spand You can try with other frameworks and result will be the same.
Wonderful arguments all around. Please refer to standards when claiming this library is not compliant.
Which standard would you like to use:
- https://www.ietf.org/rfc/rfc1738.txt
- https://tools.ietf.org/html/rfc3986
- https://tools.ietf.org/html/rfc3987
- https://url.spec.whatwg.org/
Why are you quoting URL standards when this issue is about encoding URLs in HTML?
Please see https://stackoverflow.com/questions/3705591/do-i-encode-ampersands-in-a-href for related discussions.
Which standard would you like to use as a basis for your position?