unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH][BUG]: eww doesnt trim whitespace from address
@ 2014-03-21  9:27 Vibhav Pant
  2014-11-03 13:46 ` Ted Zlatanov
  0 siblings, 1 reply; 4+ messages in thread
From: Vibhav Pant @ 2014-03-21  9:27 UTC (permalink / raw)
  To: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

As of now, eww does not rim the user specified address, this often
leads to problems especially if the address is from the clipboard (eww
reports that the service isnt known). Most browsers automatically do
this, so I have included a patch to solve this problem.

This patch simply setq's url to a "trimmed" version of it.
The change is pretty non trivial, so I think it can be included in this release.

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index e8eb09c..aa3e245 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -153,6 +153,10 @@ See also `eww-form-checkbox-selected-symbol'."
 If the input doesn't look like an URL or a domain name, the
 word(s) will be searched for via `eww-search-prefix'."
   (interactive "sEnter URL or keywords: ")
+  (setq url (replace-regexp-in-string (rx (or (: bos (* (any " \t\n")))
+                                             (: (* (any " \t\n")) eos)))
+                                     ""
+                                     url))
   (cond ((string-match-p "\\`file://" url))
         ((string-match-p "\\`ftp://" url)
          (user-error "FTP is not supported."))

-- 
Vibhav Pant
vibhavp@gmail.com

[-- Attachment #2: ewwtrim.patch --]
[-- Type: text/x-patch, Size: 717 bytes --]

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index e8eb09c..aa3e245 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -153,6 +153,10 @@ See also `eww-form-checkbox-selected-symbol'."
 If the input doesn't look like an URL or a domain name, the
 word(s) will be searched for via `eww-search-prefix'."
   (interactive "sEnter URL or keywords: ")
+  (setq url (replace-regexp-in-string (rx (or (: bos (* (any " \t\n")))
+                                             (: (* (any " \t\n")) eos)))
+                                     ""
+                                     url))
   (cond ((string-match-p "\\`file://" url))
         ((string-match-p "\\`ftp://" url)
          (user-error "FTP is not supported."))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH][BUG]: eww doesnt trim whitespace from address
  2014-03-21  9:27 [PATCH][BUG]: eww doesnt trim whitespace from address Vibhav Pant
@ 2014-11-03 13:46 ` Ted Zlatanov
  2014-11-03 14:49   ` Yuri Khan
  0 siblings, 1 reply; 4+ messages in thread
From: Ted Zlatanov @ 2014-11-03 13:46 UTC (permalink / raw)
  To: emacs-devel; +Cc: Vibhav Pant

On Fri, 21 Mar 2014 14:57:37 +0530 Vibhav Pant <vibhavp@gmail.com> wrote: 

VP> As of now, eww does not rim the user specified address, this often
VP> leads to problems especially if the address is from the clipboard (eww
VP> reports that the service isnt known). Most browsers automatically do
VP> this, so I have included a patch to solve this problem.

VP> This patch simply setq's url to a "trimmed" version of it.
VP> The change is pretty non trivial, so I think it can be included in this release.

I think the fairly recent function `string-trim' would be better than
the proposed regex approach.

I also don't know if there are any exceptions to this--are there cases
where you want to preserve the trailing space on a URL and/or encode
them to "%20"?

Thanks
Ted




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][BUG]: eww doesnt trim whitespace from address
  2014-11-03 13:46 ` Ted Zlatanov
@ 2014-11-03 14:49   ` Yuri Khan
  2014-11-04 16:33     ` Ted Zlatanov
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri Khan @ 2014-11-03 14:49 UTC (permalink / raw)
  To: Emacs developers; +Cc: Vibhav Pant

On Mon, Nov 3, 2014 at 7:46 PM, Ted Zlatanov <tzz@lifelogs.com> wrote:

> I also don't know if there are any exceptions to this--are there cases
> where you want to preserve the trailing space on a URL and/or encode
> them to "%20"?

For what it’s worth, the HTML5 specification now defines all
URL-valued attributes as “valid non-empty URL potentially surrounded
by spaces” and prescribes stripping out the surrounding spaces.

<a href=" &#x09;http://google.com/   &#x0a;">This is valid and leads
to Google</a>

eww could treat the user-specified URL similarly. Spaces at the end of
URL are rare (and at the beginning pretty much inexistent), and if the
user wants an explicit space at the end of URL, s?he can type an
explicit %20, + or other context-specific escape.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][BUG]: eww doesnt trim whitespace from address
  2014-11-03 14:49   ` Yuri Khan
@ 2014-11-04 16:33     ` Ted Zlatanov
  0 siblings, 0 replies; 4+ messages in thread
From: Ted Zlatanov @ 2014-11-04 16:33 UTC (permalink / raw)
  To: emacs-devel

On Mon, 3 Nov 2014 21:49:23 +0700 Yuri Khan <yuri.v.khan@gmail.com> wrote: 

YK> On Mon, Nov 3, 2014 at 7:46 PM, Ted Zlatanov <tzz@lifelogs.com> wrote:
>> I also don't know if there are any exceptions to this--are there cases
>> where you want to preserve the trailing space on a URL and/or encode
>> them to "%20"?

YK> For what it’s worth, the HTML5 specification now defines all
YK> URL-valued attributes as “valid non-empty URL potentially surrounded
YK> by spaces” and prescribes stripping out the surrounding spaces.

YK> <a href=" &#x09;http://google.com/   &#x0a;">This is valid and leads
YK> to Google</a>

YK> eww could treat the user-specified URL similarly. Spaces at the end of
YK> URL are rare (and at the beginning pretty much inexistent), and if the
YK> user wants an explicit space at the end of URL, s?he can type an
YK> explicit %20, + or other context-specific escape.

All right, I added a simple `string-trim' call to `eww'.

Thanks
Ted




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-04 16:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-21  9:27 [PATCH][BUG]: eww doesnt trim whitespace from address Vibhav Pant
2014-11-03 13:46 ` Ted Zlatanov
2014-11-03 14:49   ` Yuri Khan
2014-11-04 16:33     ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).