Example of converting utf-7 encoding to UTF-8 encoding in xss

Source: Internet
Author: User

In an xss problem encountered in this encoding problem, utf-7 and mutf-7 this encoding is used by mail, javamail should be supported, using utf-7 this is still relatively rare encoding can be used for some xss applications. Using Native jdk reports an error that does not support utf-7 encoding, which is a bug in sun jdk. Open-source jcharset. jar is a solution. You can use this jar package after buildpath. I wrote a small program and transferred the code!
Public static void main (String [] args) {// write the utf-7 encoding format to be escaped in bf, write a txt // in UTF-8 format on disk d to construct stringbufferStringBuffer bf = new StringBuffer ("+ buffers-"); try {OutputStream outputStream = new FileOutputStream ("d: \ utf-8.txt "); OutputStreamWriter outputStreamWriter = new OutputStreamWriter (outputStream," UTF-8 "); // display the format of the file encoding. // System. out. println (outputStreamWriter. getEncoding (); // write BufferedWriter bufferedWriter = new BufferedWriter (outputStreamWriter); bufferedWriter. write (new String (bf. toString (). getBytes ("UTF-8"), "utf-7"); bufferedWriter. flush (); bufferedWriter. close (); bufferedWriter = null;} catch (FileNotFoundException e) {e. printStackTrace ();} catch (UnsupportedEncodingException e) {// TODO Auto-generated catch blocke. printStackTrace ();} catch (IOException e) {// TODO Auto-generated catch blocke. printStackTrace ();}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.