你怎么连接code XML安全使用ActionScript 3? [英] How do you encode XML safely with ActionScript 3?

查看:172
本文介绍了你怎么连接code XML安全使用ActionScript 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从用户获取数据,并将其写入到一个XML字符串,像这样:

I'm capturing data from the user and writing it to an xml string like so:

VAR与myXML:XML =           {userEnteredText}    

var myXml:XML = {userEnteredText}

这是罚款和花花公子,直到用户得到可爱的有特殊字符,如&放大器;<>等非法字符也喜欢的0x19问题

This is fine and dandy until the user gets cute with special characters like "& < >" etc. Illegal characters are also a problem like 0x19.

时有方法,将sanatize我的XML和连接code特殊字符或我将不得不推出自己的?

Is there are method that will sanatize my xml and encode special characters or will I have to roll my own?

推荐答案

简单地转换字符串到textnode应该做的伎俩

simply converting the string to a textnode should do the trick

var s:String = "test<ie>test";
var x:XML = <xml/>;
x.appendChild(s);
trace(x.toXMLString());//outputs "<xml>test&lt;ie&gt;test</xml>"

此外,您还可以一下子就将这些内容进入 CTADA ...

我不知道,为什么的0x19应该是非法的......空格和nullbytes是经常掉线...但如果​​这是你想要的二进制数据,你应该使用的的base64 ...... >这里有一个lib&LT ;

i'm not sure, why 0x19 should be illegal ... whitespaces and nullbytes are often dropped ... but if it is binary data you want, you should probably use base64 ... >here's a lib<

这篇关于你怎么连接code XML安全使用ActionScript 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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