在html中的符号编码事实上的做法是什么? [英] what's the de facto practice on ampersand encoding in html

查看:89
本文介绍了在html中的符号编码事实上的做法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过html规范,&符号应该被编码为

 & amp; amp; amp; amp; amp; 

但当然很多网站并不这么做。以下是来自amazon的广告部件示例:

 < iframe 
src =http://rcm.amazon / b / t = xyzxyz-20& o = 1& p = 11& l = ur1& category = textbooks& banner = 17P1AE8RQ1T7ZFC62V82& f = ifr
width =120
height =600
scrolling =no
border =0
marginwidth =0
style =border:none;
frameborder =0>
< / iframe>

请注意,&符号未被编码。



<我的问题是,对于那些在商业网站上工作很多,在公司工作或者使用很多窗口小部件代码的人来说,这些网站中的大多数实际上是对&符号进行编码的吗?



< (换句话说,前1k网站在url中正确地编码&符号的百分比是多少?)



压力:这与它是否应该或不应该被编码。我只想问问那些在公司工作的人:如果你看过很多基于cgi的url,并且这个url在HTML页面内,那么你的经验是否被编码?

$ b $它应该是始终编码 - 或者作为& amp; 或作为&#38;



但浏览器解析器非常宽容: - )


by html spec, ampersand should be encoded as

&amp;

but of course a lot web doesn't do that. Here's a example of ad widget from amazon:

<iframe
 src="http://rcm.amazon.com/e/cm?t=xyzxyz-20&o=1&p=11&l=ur1&category=textbooks&banner=17P1AE8RQ1T7ZFC62V82&f=ifr"
width="120"
height="600"
scrolling="no"
border="0"
marginwidth="0"
style="border:none;"
frameborder="0">
</iframe>

note that the ampersand is not encoded.

My question is, for those work a lot with commercial sites, work in a company, or work with many widget codes, do most of these sites actually encode the ampersand?

(in other words, what percentage of top 1k sites try to encode ampersand properly when it is in url?)

Stress: this is not about whether it should or should not be encoded. I just want to ask those who work in companies: if you have seen a lot cgi based url that has ampersand in it, and this url is inside a html page, in your experience, are they encoded?

解决方案

It should be always encoded - either as &amp; or as &#38;

However browser parser is very forgiving :-)

这篇关于在html中的符号编码事实上的做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆