+BillP3rd Posted May 29, 2006 Share Posted May 29, 2006 When a hint contains a web link in the form [http://www.somesite.com] it's helpfully converted into a live web link. To demonstrate: [http://en.wikipedia.org/wiki/Book_cipher]'>http://en.wikipedia.org/wiki/Book_cipher] results in (]visit link) No. the extra ']' in the result isn't a typo. That's what's coming from geocaching.com. After some experimentation I've learned: [http://en.wikipedia.org/wiki/Book_cipher results in (visit link) ------- [http://en.wikipedia.org/wiki/Book_cipher This is a test [This is a test] results in (visit link) This is a test [This is a test] ------- [Link:] [http://en.wikipedia.org/wiki/Book_cipher]'>http://en.wikipedia.org/wiki/Book_cipher] This is a test [This is a test] results in [Link:] (]visit link) Guvf vf n grfg [This is a test] ------- [Link:] [http://en.wikipedia.org/wiki/Book_cipher ]This is a test [This is a test] results in [Link:] (visit link) ]Guvf vf n grfg [This is a test] which decrypts to: [Link:] (ivfvg yvax) ]This is a test[This is a test] ------- If there's interest by Groundspeak I'll be happy to fix the decrypting problem with the link (It should take about 10 minutes to write and test). The presentation problem appears to be on the server side. Link to comment
+BillP3rd Posted May 29, 2006 Author Share Posted May 29, 2006 This code fixes the decrypting problem (both with the anchor tag AND the line breaking problem). function convertROTStringWithBrackets(s) { if (!rot13array) rot13array=createROT13array(); var sChar = ""; var sOutput = ""; var bDecrypt = true; for( i = 0; i < s.length; i++) { sChar = s.charAt(i); // **** START OF FIX **** // check for break and anchor tags if ( i < (s.length - 4) ) { if ( s.toLowerCase().substr( i, 4 ) == "<br>" ) { // is line break sOutput += "<br>"; i += 3; continue; } else if ( s.toLowerCase().substr( i, 3 ) == "<a " ) { // start of anchor bDecrypt = false; sOutput += "<a "; i += 2; continue; } else if ( s.toLowerCase().substr( i, 4 ) == "</a>" ) { // end of anchor bDecrypt = true; sOutput += "</a>"; i += 3; continue; } } // **** END OF FIX **** // ignore any text enclosed in [ ] brackets if (sChar == "[") bDecrypt = false; else if (sChar == "]") bDecrypt = true; else if ( (sChar == " ") || (sChar == "&dhbg;") ) { // do nothing } else { if (bDecrypt) sChar = convertROT13Char(sChar); } sOutput += sChar; } return sOutput; } Link to comment
Recommended Posts