unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16285: 24.3.50; [PATCH] shr: handle <a> tag with blank error.
@ 2013-12-29 13:08 Kenjiro NAKAYAMA
  2014-01-05  9:48 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Kenjiro NAKAYAMA @ 2013-12-29 13:08 UTC (permalink / raw)
  To: 16285

If there is <a> tag with blank, the internal link will fail.
Please reproduce the bug by following HTML.
(Internal link "section1" can not jump to internal link.)
I am not sure following patch is the best fix. Please review and
install it to the official tree if appreciated.

~~~~~~~~~~~~~~~
<html>
<head><title>INTERNAL LINK TEST</title></head>
<body>
<li><a href="#section1">section1</a></li>
<br>
  --- TEST ---
<br>
<a id="section1"></a>link test
</body>
</html>
~~~~~~~~~~~~~~~


Signed-off-by: Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com>

          * net/eww.el (shr-descend): Handle <a> tag with blank error.
          
---
 lisp/net/shr.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 1604ebb..20dd31f 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -380,7 +380,11 @@ size, and full-buffer size."
        (shr-generic (cdr dom)))
       (when (and shr-target-id
                 (equal (cdr (assq :id (cdr dom))) shr-target-id))
-       (put-text-property start (1+ start) 'shr-target-id shr-target-id))
+       (let ((result (ignore-errors
+                       (put-text-property start (1+ start) 'shr-target-id shr-target-id)
+                       t)))
+         (unless result
+           (put-text-property start (1- start) 'shr-target-id shr-target-id))))
       ;; If style is set, then this node has set the color.
       (when style
        (shr-colorize-region start (point)
-- 
1.8.3.1






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

* bug#16285: 24.3.50; [PATCH] shr: handle <a> tag with blank error.
  2013-12-29 13:08 bug#16285: 24.3.50; [PATCH] shr: handle <a> tag with blank error Kenjiro NAKAYAMA
@ 2014-01-05  9:48 ` Lars Magne Ingebrigtsen
  2014-01-05 11:47   ` Kenjiro NAKAYAMA
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Magne Ingebrigtsen @ 2014-01-05  9:48 UTC (permalink / raw)
  To: Kenjiro NAKAYAMA; +Cc: 16285

Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com> writes:

>           * net/eww.el (shr-descend): Handle <a> tag with blank error.

I've now fixed this in a different manner.  Your patch would have bugged
out if the empty anchor was the first element in the buffer, so I just
made it insert a "*" if we have an empty anchor.

The anchoring mechanism should perhaps be implemented in a different
way -- markers instead of text properties, for instance?  That way
zero-length anchors would be no problem.  Rewriting it in that way
should probably wait until after the feature freeze, though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#16285: 24.3.50; [PATCH] shr: handle <a> tag with blank error.
  2014-01-05  9:48 ` Lars Magne Ingebrigtsen
@ 2014-01-05 11:47   ` Kenjiro NAKAYAMA
  0 siblings, 0 replies; 3+ messages in thread
From: Kenjiro NAKAYAMA @ 2014-01-05 11:47 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: Kenjiro NAKAYAMA, 16285

> I've now fixed this in a different manner.  Your patch would have bugged
> out if the empty anchor was the first element in the buffer, so I just
> made it insert a "*" if we have an empty anchor.

Thanks!

> The anchoring mechanism should perhaps be implemented in a different
> way -- markers instead of text properties, for instance?  That way

The markers is good idea. Inserting "*" is not bad,
but if it is possible, markers is good.

Kenjiro

larsi@gnus.org writes:

> Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com> writes:
>
>>           * net/eww.el (shr-descend): Handle <a> tag with blank error.
>
> I've now fixed this in a different manner.  Your patch would have bugged
> out if the empty anchor was the first element in the buffer, so I just
> made it insert a "*" if we have an empty anchor.
>
> The anchoring mechanism should perhaps be implemented in a different
> way -- markers instead of text properties, for instance?  That way
> zero-length anchors would be no problem.  Rewriting it in that way
> should probably wait until after the feature freeze, though.






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

end of thread, other threads:[~2014-01-05 11:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-29 13:08 bug#16285: 24.3.50; [PATCH] shr: handle <a> tag with blank error Kenjiro NAKAYAMA
2014-01-05  9:48 ` Lars Magne Ingebrigtsen
2014-01-05 11:47   ` Kenjiro NAKAYAMA

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).