diff --git a/res/about/version.gmi b/res/about/version.gmi

index b840987f..b3b29aef 100644

--- a/res/about/version.gmi

+++ b/res/about/version.gmi

@@ -9,6 +9,7 @@

1.0.3

+* Fixed percent-encoding of spaces when copying URLs to clipboard.

diff --git a/src/gmutil.c b/src/gmutil.c

index ab9a8eea..69fa6d9f 100644

--- a/src/gmutil.c

+++ b/src/gmutil.c

@@ -327,6 +327,12 @@ void urlEncodeSpaces_String(iString *d) {

 }

}



+const iString *withSpacesEncoded_String(const iString *d) {

+ iString *enc = copy_String(d);

+ urlEncodeSpaces_String(enc);

+ return collect_String(enc);

+}

+

const iString *feedEntryOpenCommand_String(const iString *url, int newTab) {

 if (!isEmpty_String(url)) {

     iString *cmd = collectNew_String();

diff --git a/src/gmutil.h b/src/gmutil.h

index 947ff56b..7227a072 100644

--- a/src/gmutil.h

+++ b/src/gmutil.h

@@ -110,5 +110,6 @@ void urlEncodePath_String (iString *);

iString * makeFileUrl_String (const iString *localFilePath);

const char * makeFileUrl_CStr (const char *localFilePath);

void urlEncodeSpaces_String (iString *);

+const iString * withSpacesEncoded_String(const iString *);



const iString * feedEntryOpenCommand_String (const iString url, int newTab); / checks fragment */

diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c

index 423286ea..e5475ea5 100644

--- a/src/ui/documentwidget.c

+++ b/src/ui/documentwidget.c

@@ -1613,11 +1613,11 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)

 }

 else if (equal_Command(cmd, "document.copylink") && document_App() == d) {

     if (d->contextLink) {

- SDL_SetClipboardText(cstr_String(

- absoluteUrl_String(d->mod.url, linkUrl_GmDocument(d->doc, d->contextLink->linkId))));

+ SDL_SetClipboardText(cstr_String(withSpacesEncoded_String(absoluteUrl_String(

+ d->mod.url, linkUrl_GmDocument(d->doc, d->contextLink->linkId)))));

     }

     else {

- SDL_SetClipboardText(cstr_String(d->mod.url));

+ SDL_SetClipboardText(cstr_String(withSpacesEncoded_String(d->mod.url)));

     }

     return iTrue;

 }

diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c

index 85bd8b8b..6992bbec 100644

--- a/src/ui/inputwidget.c

+++ b/src/ui/inputwidget.c

@@ -514,8 +514,10 @@ static size_t coordIndex_InputWidget_(const iInputWidget *d, iInt2 coord) {

static iBool copy_InputWidget_(iInputWidget *d, iBool doCut) {

 if (!isEmpty_Range(&d->mark)) {

     const iRanges m = mark_InputWidget_(d);

- SDL_SetClipboardText(cstrCollect_String(

- newUnicodeN_String(constAt_Array(&d->text, m.start), size_Range(&m))));

+ iString *str = collect_String(newUnicodeN_String(constAt_Array(&d->text, m.start),

+ size_Range(&m)));

+ SDL_SetClipboardText(

+ cstr_String(d->inFlags & isUrl_InputWidgetFlag ? withSpacesEncoded_String(str) : str));

     if (doCut) {

         pushUndo_InputWidget_(d);

         deleteMarked_InputWidget_(d);

diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c

index a4cfd8a9..46fab22d 100644

--- a/src/ui/sidebarwidget.c

+++ b/src/ui/sidebarwidget.c

@@ -734,7 +734,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)

     else if (isCommand_Widget(w, ev, "bookmark.copy")) {

         const iSidebarItem *item = d->contextItem;

         if (d->mode == bookmarks_SidebarMode && item) {

- SDL_SetClipboardText(cstr_String(&item->url));

+ SDL_SetClipboardText(cstr_String(withSpacesEncoded_String(&item->url)));

         }

         return iTrue;

     }

@@ -955,7 +955,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)

     else if (isCommand_Widget(w, ev, "history.copy")) {

         const iSidebarItem *item = d->contextItem;

         if (item && !isEmpty_String(&item->url)) {

- SDL_SetClipboardText(cstr_String(&item->url));

+ SDL_SetClipboardText(cstr_String(withSpacesEncoded_String(&item->url)));

         }

         return iTrue;

     }

Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.8/pcdiff/531438897f22b812564e6b989192fea6c26e8b14
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
65.941899 milliseconds
Gemini-to-HTML Time
1.525117 milliseconds

This content has been proxied by September (ba2dc).