Project

General

Profile

« Previous | Next » 

Revision 7678

escape reserved XML characters when constructing a pathquery from user input (&). https://projects.ecoinformatics.org/ecoinfo/issues/3017

View differences:

search.js
1
function encodeXML(theString) {
2
	return theString.replace(/&/g, '&')
3
		.replace(/</g, '&lt;')
4
		.replace(/>/g, '&gt;')
5
		.replace(/"/g, '&quot;');
6
}
7

  
1 8
function trim(stringToTrim) {
2 9
    return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
3 10
}
4 11

  
5 12
function checkSearch(submitFormObj) {
6 13
    var searchString = trim(submitFormObj.searchstring.value);
14
	searchString = encodeXML(searchString);
7 15
    var checkBox = document.getElementById("searchAll");
8 16

  
9 17
    if (searchString=="") {

Also available in: Unified diff