Matthew Toseland wrote:
> On Monday 11 June 2007 18:48, David Sowder wrote:
>
>> Matthew Toseland wrote:
>>
>>> On Monday 11 June 2007 18:14, David Sowder wrote:
>>>
>>>> Matthew Toseland wrote:
>>>>
>>>>> Is this necessary?
>>>>>
>>>> Yes. I managed to create a bookmark I couldn't manage later. It
>>>> contained a "&" character.
>>>>
>>> I don't understand why. Anything that goes through HTMLNode is
>>> automatically HTMLEncode'd.
>>>
>> Yeah, I noticed, but when I tried using HTMLEncoder rather than
>> URLEncoder, it didn't fix the problem, so maybe that's why the auto
>> thing didn't handle it.
>>
>
> Are we talking about inline body text, or tag parameters?
>
I'm not quite sure what you mean by that question, but I'll attempt to
answer it with statements.
A bookmark of mine contained an "&" character, which I had no trouble
naming that way.
I could not manage that bookmark in any way because the interface would
return an error saying the bookmark didn't exist with the "&" and any
remaining characters truncated from the name it said it couldn't find.
The interface uses the bookmark name passed in the URL GET form style by
constructing a URL with the appropriate GET form style arguments,
including the bookmark's name.
The fix I found and committed with r13509 was to URLEncode the
bookmark's name when including it in the URL and then URLDecoding it
when receiving it as an argument.
>>>>> On Sunday 10 June 2007 21:01, you wrote:
>>>>>
>>>>>> Author: zothar
>>>>>> Date: 2007-06-10 20:01:10 +0000 (Sun, 10 Jun 2007)
>>>>>> New Revision: 13509
>>>>>>
>>>>>> Modified:
>>>>>> trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
>>>>>> trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
>>>>>> Log:
>>>>>> Use URL encoding in BookmarkEditorToadlet
>>>>>>
>>>>>> Modified:
>>>>>> trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
>>>>>> ===================================================================
>>>>>> ---
>>>>>> trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
>>>>>> 2007
>>>>>> -0 6-0 9 21:38:28 UTC (rev 13508) +++
>>>>>> trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
>>>>>> 2007
>>>>>> -0 6-1 0 20:01:10 UTC (rev 13509) @@ -16,6 +16,9 @@
>>>>>> import freenet.node.NodeClientCore;
>>>>>> import freenet.client.HighLevelSimpleClient;
>>>>>> import freenet.support.HTMLNode;
>>>>>> +import freenet.support.URLDecoder;
>>>>>> +import freenet.support.URLEncodedFormatException;
>>>>>> +import freenet.support.URLEncoder;
>>>>>> import freenet.support.api.HTTPRequest;
>>>>>>
>>>>>> public class BookmarkEditorToadlet extends Toadlet {
>>>>>> @@ -53,8 +56,8 @@
>>>>>>
>>>>>> for(int i = 0; i < items.size(); i++) {
>>>>>>
>>>>>> - String itemPath = path + items.get(i).getName();
>>>>>> - HTMLNode li = new HTMLNode("li", "class","item"
>>>>>> ,
>>>>>> items.get(i).getName()); + String itemPath =
>>>>>> URLEncoder.encode(path
>>>>>> + items.get(i).getName()); + HTMLNode li = new
>>>>>> HTMLNode("li",
>>>>>> "class", "item" , items.get(i).getName());
>>>>>>
>>>>>> HTMLNode actions = new HTMLNode("span",
>>>>>> "class", "actions");
>>>>>> actions.addChild("a", "href",
>>>>>> "?action=edit&bookmark=" +
>>>>>> itemPath).addChild("img", new String[] {"src", "alt", "title"}, new
>>>>>> String[] {"/static/icon/edit.png", edit, edit}); @@ -77,7 +80,7 @@
>>>>>> BookmarkCategories cats = cat.getSubCategories();
>>>>>> for(int i = 0; i < cats.size(); i++) {
>>>>>>
>>>>>> - String catPath = path + cats.get(i).getName() +
>>>>>> "/";
>>>>>> + String catPath = URLEncoder.encode(path +
>>>>>> cats.get(i).getName() +
>>>>>> "/");
>>>>>>
>>>>>> HTMLNode subCat = list.addChild("li", "class",
>>>>>> "cat",
>>>>>> cats.get(i).getName());
>>>>>>
>>>>>> @@ -141,7 +144,15 @@
>>>>>>
>>>>>> if (req.getParam("action").length() > 0 &&
>>>>>> req.getParam("bookmark").length() > 0) { String action =
>>>>>> req.getParam("action");
>>>>>> - String bookmarkPath = req.getParam("bookmark");
>>>>>> + String bookmarkPath;
>>>>>> + try {
>>>>>> + bookmarkPath =
>>>>>> URLDecoder.decode(req.getParam("bookmark"),
>>>>>> false); + } catch (URLEncodedFormatException e) {
>>>>>> + HTMLNode errorBox =
>>>>>> content.addChild(ctx.getPageMaker().getInfobox("infobox-error",
>>>>>> error)); + errorBox.addChild("#",
>>>>>> L10n.getString("BookmarkEditorToadlet.urlDecodeError"));
>>>>>> + this.writeReply(ctx, 200, "text/html",
>>>>>> "OK",
>>>>>> pageNode.generate()); + return;
>>>>>> + }
>>>>>> Bookmark bookmark;
>>>>>>
>>>>>> if (bookmarkPath.endsWith("/"))
>>>>>>
>>>>>> Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
>>>>>> ===================================================================
>>>>>> ---
>>>>>> trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
>>>>>> 2007-06-09
>>>>>> 21:38:28 UTC (rev 13508) +++
>>>>>> trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
>>>>>> 2007-06-10
>>>>>> 20:01:10 UTC (rev 13509) @@ -34,6 +34,7 @@
>>>>>> BookmarkEditorToadlet.pasteTitle=Cut/Paste
>>>>>> BookmarkEditorToadlet.save=Save
>>>>>> BookmarkEditorToadlet.title=Bookmark Editor
>>>>>> +BookmarkEditorToadlet.urlDecodeError=URL Decode Error
>>>>>> BookmarkItem.bookmarkUpdated=The bookmarked site ${name} has been
>>>>>> updated to edition ${edition}.
>>>>>> BookmarkItem.bookmarkUpdatedTitle=Bookmark Updated: ${name}
>>>>>> BookmarkItem.bookmarkUpdatedWithLink=The bookmarked site
>>>>>> ${link}${name}${/link} has been updated to edition ${edition}.