Jump to content

Another Hints Bug


BillP3rd

Recommended Posts

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:

 

[
]'>
]

results in

(
)

No. the extra ']' in the result isn't a typo. That's what's coming from geocaching.com. After some experimentation I've learned:

 

[

results in

(
)

-------

[

This is a test

[This is a test]

results in

(
)

This is a test

[This is a test]

-------

[Link:] [
]'>
]

This is a test

[This is a test]

results in

[Link:] (
)

Guvf vf n grfg

[This is a test]

-------

[Link:] [

]This is a test

[This is a test]

results in

[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

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
Guest
This topic is now closed to further replies.
×
×
  • Create New...