Skip Menu |

This queue is for tickets about the Markdent CPAN distribution.

Report information
The Basics
Id: 92251
Status: resolved
Priority: 0/
Queue: Markdent

People
Owner: Nobody in particular
Requestors: PJF [...] cpan.org
cpan [...] zoffix.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Links containing spaces are not parsed correctly
The markdown standard says that links can have an optional title, which must be enclosed in double quotes. However markdent considers anything past the first space in a URL to be the title, and cares not for quotes. This means a URL like: [some text](http://example.com/Your Page.html) results in a truncated URL of `http://example.com/Your`. This should be a simple tweak to `Markdent::Parser::SpanParser::_parse_uri_and_title()`, but it appears that I can't brain today, so a patch is not yet included. ~ pjf
Subject: [PATCH] for RT#92251
Subject: SpanParser-URL-Title-Handling.patch
diff --git a/lib/Markdent/Parser/SpanParser.pm b/lib/Markdent/Parser/SpanParser.pm index c1c5779..32f5205 100644 --- a/lib/Markdent/Parser/SpanParser.pm +++ b/lib/Markdent/Parser/SpanParser.pm @@ -140,14 +140,14 @@ sub _parse_uri_and_title { $text =~ s/^\s+|\s+$//g; - my ( $uri, $title ) = split /(?:\p{SpaceSeparator}|\t)+/, $text, 2; + my $title; + ( my $uri = $text ) =~ s/\s+(['"])(.+?)\1$//s + and $title = $2; $uri = q{} unless defined $uri; - $uri =~ s/^<|>$//g; - $title =~ s/^"|"$//g - if defined $title; + $uri =~ s/^<|>$//g; return ( $uri, $title ); }
Patch supplied: https://rt.cpan.org/Ticket/Display.html?id=92273 Thanks for reporting.
On Sun Jan 19 20:24:19 2014, ZOFFIX wrote: Show quoted text
> Attached is the patch that fixes > https://rt.cpan.org/Ticket/Display.html?id=92251 > > Cheers, > ZZ [ https://metacpan.org/author/ZOFFIX ]
For future reference, you can just comment on the original ticket. Thanks, -dave
On Sat Jan 18 03:12:01 2014, PJF wrote: Show quoted text
> The markdown standard says that links can have an optional title, > which must be enclosed in double quotes. However markdent considers > anything past the first space in a URL to be the title, and cares not > for quotes. This means a URL like: > > [some text](http://example.com/Your Page.html)
Is this actually a valid link? Shouldn't that be Your%20Page.html?
On Sat Jan 25 17:20:35 2014, DROLSKY wrote: Show quoted text
> Is this actually a valid link? Shouldn't that be Your%20Page.html?
It's not a valid link, but in the sense that browsers will interpret the space as %20, follow it properly, display it in the URL bar as a space, and escape it to %20 when copy/pasting from URL bar, then it's "valid" :) Here's a test case: http://zoffix.com/new/del/space%20in-link.html And its validation: http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fzoffix.com%2Fnew%2Fdel%2Fspace%2520in-link.html One thing to note is that markdown specifies the optional title has to be quoted, so assuming there's a title by splitting on a space isn't correct. (I've used this document for my reference: http://daringfireball.net/projects/markdown/syntax#link ) -- Cheers, ZZ [ https://metacpan.org/author/ZOFFIX ]