unescape MultiProtocolURL getAttributes() return values.

use getAttributes() to get query parameters as clear text (w/o url encoding)
use getSearchpartMap() to get in internal format (url encoded)

fix for http://mantis.tokeek.de/view.php?id=606
pull/18/head
reger 10 years ago
parent 10b0eb106f
commit c9937973e3

@ -93,7 +93,9 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
f.setAttribute("enctype", "multipart/form-data"); f.setAttribute("enctype", "multipart/form-data");
f.setAttribute("accept-charset", "UTF-8"); f.setAttribute("accept-charset", "UTF-8");
f.setAttribute("action", "#[servlet]#"); f.setAttribute("action", "#[servlet]#");
f.setAttribute("target", "_parent");
f.setAttribute("id", "#[pk]#"); f.setAttribute("id", "#[pk]#");
f.setAttribute("name", "#[pk]#");
#{attr}# #{attr}#
var e = document.createElement("input"); var e = document.createElement("input");
e.setAttribute("type", "hidden"); e.setAttribute("type", "hidden");
@ -103,7 +105,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
#{/attr}# #{/attr}#
document.body.appendChild(f); document.body.appendChild(f);
</script> </script>
<a href="#" title="clone" target="_parent" onclick="document.forms['#[pk]#'].submit(); return false;"><img src="env/grafics/doc.gif"><img src="env/grafics/right.gif"><img src="env/grafics/doc.gif"></a> <a href="#" title="clone" onclick="document.forms['#[pk]#'].submit(); return false;"><img src="env/grafics/doc.gif"><img src="env/grafics/right.gif"><img src="env/grafics/doc.gif"></a>
#(/isCrawlerStart)#</td> #(/isCrawlerStart)#</td>
<td valign="top">#[comment]#</td> <td valign="top">#[comment]#</td>

@ -945,6 +945,14 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
return this.searchpart; return this.searchpart;
} }
/**
* Returns a search part parameter map key=value
* in internal url encoded format
* for unescaped return values
* @see #getAttributes()
*
* @return key name value
*/
public Map<String, String> getSearchpartMap() { public Map<String, String> getSearchpartMap() {
if (this.searchpart == null) return null; if (this.searchpart == null) return null;
this.searchpart = this.searchpart.replaceAll("&amp;", "&"); this.searchpart = this.searchpart.replaceAll("&amp;", "&");
@ -1027,6 +1035,10 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
/** /**
* Evaluates url search part and returns attribute '=' value pairs * Evaluates url search part and returns attribute '=' value pairs
* the returned values are in clear text (without urlencoding).
*
* To get the parameter map as (url-encoded key and values)
* @see getSearchpartMap()
* *
* @return map key=attribue name, value=string after '=' * @return map key=attribue name, value=string after '='
*/ */
@ -1037,9 +1049,9 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
for (final String element : questp) { for (final String element : questp) {
int p = element.indexOf('='); int p = element.indexOf('=');
if (p != -1) { if (p != -1) {
map.put(element.substring(0, p), element.substring(p + 1)); map.put(unescape(element.substring(0, p)), unescape(element.substring(p + 1)));
} else { } else {
if (!element.isEmpty()) map.put(element, ""); if (!element.isEmpty()) map.put(unescape(element), "");
} }
} }
return map; return map;

Loading…
Cancel
Save