(LSL) string strURL2Use = URL_POLL_DATA; strURL2Use += llEscapeURL("?proj=" + strExpenseProjectData); strURL2Use += llEscapeURL("?type=" + strExpenseTypeData); strURL2Use += llEscapeURL("?amount=" + strExpenseAmount); strURL2Use += llEscapeURL("?note=" + strExpenseTypeNote);
// klEscapeURL(string src) // Returns the string src with URL escaping. (Replaces spaces by %20, etc) string klEscapeURL(string src) { string tmp; integer pos; // i read somewhere that jumps were more efficient than for loops. Haven't tested it myself, but using them anyway. @loop0; pos = llSubStringIndex(src, "%"); if(pos != -1) { // There's probably a more effecient way to do this, but i wrote this quickly without thinking too much up front. // Can't do llSubStringIndex() constantly because it would keep returning the first, replacing it with %25 and then // reporting the % in that one, so making an endless loop. So i take the first part of the string out and store it // temporarily, then continue on the remaining part until there's no more %'s in it. tmp += llGetSubString(src, 0, --pos) + "%25"; src = llDeleteSubString(src, 0, ++pos); jump loop0; } src = tmp + src; @loop1; pos = llSubStringIndex(src, " "); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%20"); jump loop1; } @loop2; pos = llSubStringIndex(src, "<"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%3C"); jump loop2; } @loop3; pos = llSubStringIndex(src, ">"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%3E"); jump loop3; } @loop4; pos = llSubStringIndex(src, "#"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%23"); jump loop4; } @loop5; pos = llSubStringIndex(src, "{"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%7B"); jump loop5; } @loop6; pos = llSubStringIndex(src, "}"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%7D"); jump loop6; } @loop7; pos = llSubStringIndex(src, "|"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%7C"); jump loop7; } @loop8; pos = llSubStringIndex(src, "\\"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%5C"); jump loop8; } @loop9; pos = llSubStringIndex(src, "^"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%5E"); jump loop9; } @loop10; pos = llSubStringIndex(src, "~"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%7E"); jump loop10; } @loop11; pos = llSubStringIndex(src, "["); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%5B"); jump loop11; } @loop12; pos = llSubStringIndex(src, "]"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%5D"); jump loop12; } @loop13; pos = llSubStringIndex(src, "`"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%60"); jump loop13; } @loop14; pos = llSubStringIndex(src, ";"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%3B"); jump loop14; } @loop15; pos = llSubStringIndex(src, "/"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%2F"); jump loop15; } @loop16; pos = llSubStringIndex(src, "?"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%3F"); jump loop16; } @loop17; pos = llSubStringIndex(src, ":"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%3A"); jump loop17; } @loop18; pos = llSubStringIndex(src, "@"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%40"); jump loop18; } @loop19; pos = llSubStringIndex(src, "="); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%3D"); jump loop19; } @loop20; pos = llSubStringIndex(src, "&"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%26"); jump loop20; } @loop21; pos = llSubStringIndex(src, "$"); if(pos != -1) { src = llDeleteSubString(src, pos, pos); src = llInsertString(src, pos, "%24"); jump loop21; } return src; }