From e1f09e1cc227e560b86631fc9f018d2829ed648a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 20:13:09 +0200 Subject: [PATCH 1/2] Show the noderef in basic-mode: it is now robust enough Previously the noderef was hidden in basic mode to get people to send it as file, because line terminators made problems (\n vs \r\n vs \r) and inserted linebreaks broke the noderef. It has been made much more resilient since then, so the added click is now a bigger problem than potential breakage due to corruption. --- src/freenet/clients/http/DarknetAddRefToadlet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/clients/http/DarknetAddRefToadlet.java b/src/freenet/clients/http/DarknetAddRefToadlet.java index 9c4b865becd..f8e4d1105eb 100644 --- a/src/freenet/clients/http/DarknetAddRefToadlet.java +++ b/src/freenet/clients/http/DarknetAddRefToadlet.java @@ -86,7 +86,7 @@ public void handleMethodGET(URI uri, final HTTPRequest request, ToadletContext c ConnectionsToadlet.drawAddPeerBox(contentNode, ctx, false, friendsToadlet.path()); - friendsToadlet.drawNoderefBox(contentNode, getNoderef(), pageMaker.advancedMode(request, this.container)); + friendsToadlet.drawNoderefBox(contentNode, getNoderef(), true); this.writeHTMLReply(ctx, 200, "OK", pageNode.generate()); } From cb322b8c78ae877cf15534d042fd3548d34b30ba Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 3 Sep 2023 16:09:32 +0200 Subject: [PATCH 2/2] Remove no longer used showNoderef parameter --- .../clients/http/ConnectionsToadlet.java | 20 ++++++++----------- .../clients/http/DarknetAddRefToadlet.java | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/freenet/clients/http/ConnectionsToadlet.java b/src/freenet/clients/http/ConnectionsToadlet.java index eb5d752eff5..3c5cb072bb4 100644 --- a/src/freenet/clients/http/ConnectionsToadlet.java +++ b/src/freenet/clients/http/ConnectionsToadlet.java @@ -588,7 +588,7 @@ public void handleMethodGET(URI uri, final HTTPRequest request, ToadletContext c // our reference if(shouldDrawNoderefBox(advancedMode)) { drawAddPeerBox(contentNode, ctx); - drawNoderefBox(contentNode, getNoderef(), true); + drawNoderefBox(contentNode, getNoderef()); } this.writeHTMLReply(ctx, 200, "OK", pageNode.generate()); @@ -863,13 +863,10 @@ protected void handleAltPost(URI uri, HTTPRequest request, ToadletContext ctx, b final HTMLNode REFTEXT_LINK; /** - * * @param contentNode Node to add noderef box to. * @param fs Noderef to render as text if requested. - * @param showNoderef If true, render the text of the noderef so that it may be copy-pasted. If false, only - * show a link to download it. */ - void drawNoderefBox(HTMLNode contentNode, SimpleFieldSet fs, boolean showNoderef) { + void drawNoderefBox(HTMLNode contentNode, SimpleFieldSet fs) { HTMLNode referenceInfobox = contentNode.addChild("div", "class", "infobox infobox-normal"); HTMLNode headerReferenceInfobox = referenceInfobox.addChild("div", "class", "infobox-header"); // FIXME better way to deal with this sort of thing??? @@ -888,13 +885,12 @@ void drawNoderefBox(HTMLNode contentNode, SimpleFieldSet fs, boolean showNoderef myName.addChild("span", "]"); } - if (showNoderef) { - HTMLNode warningSentence = referenceInfoboxContent.addChild("p"); - NodeL10n.getBase().addL10nSubstitution(warningSentence, "DarknetConnectionsToadlet.referenceCopyWarning", - new String[] { "bold" }, - new HTMLNode[] { HTMLNode.STRONG }); - referenceInfoboxContent.addChild("pre", "id", "reference", fs.toOrderedStringWithBase64() + '\n'); - } + HTMLNode warningSentence = referenceInfoboxContent.addChild("p"); + NodeL10n.getBase().addL10nSubstitution(warningSentence, "DarknetConnectionsToadlet.referenceCopyWarning", + new String[] { "bold" }, + new HTMLNode[] { HTMLNode.STRONG }); + referenceInfoboxContent.addChild("pre", "id", "reference", fs.toOrderedStringWithBase64() + '\n'); + } protected abstract String getPageTitle(String titleCountString); diff --git a/src/freenet/clients/http/DarknetAddRefToadlet.java b/src/freenet/clients/http/DarknetAddRefToadlet.java index f8e4d1105eb..5b6c7e6bbe9 100644 --- a/src/freenet/clients/http/DarknetAddRefToadlet.java +++ b/src/freenet/clients/http/DarknetAddRefToadlet.java @@ -86,7 +86,7 @@ public void handleMethodGET(URI uri, final HTTPRequest request, ToadletContext c ConnectionsToadlet.drawAddPeerBox(contentNode, ctx, false, friendsToadlet.path()); - friendsToadlet.drawNoderefBox(contentNode, getNoderef(), true); + friendsToadlet.drawNoderefBox(contentNode, getNoderef()); this.writeHTMLReply(ctx, 200, "OK", pageNode.generate()); }