Permalink
Browse files

If a link is invalid for A HREF, then now creating the NSURL is retri…

…ed with the URL string percent-escaped.
  • Loading branch information...
1 parent 3ec7b3a commit acc0dfcc7c5062e0fbbb39971211e7ce3e04cfd1 @odrobnik odrobnik committed Dec 5, 2011
Showing with 9 additions and 3 deletions.
  1. +8 −0 Core/Source/NSAttributedString+HTML.m
  2. +1 −3 Demo/Resources/CurrentTest.html
@@ -414,6 +414,14 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
if ([cleanString length])
{
link = [NSURL URLWithString:cleanString relativeToURL:baseURL];
+
+ if (!link)
+ {
+ // NSURL did not like the link, so let's encode it
+ cleanString = [cleanString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+
+ link = [NSURL URLWithString:cleanString relativeToURL:baseURL];
+ }
}
else
{
@@ -1,3 +1 @@
-<html style="text-align:center;">
- <h1>The Title</h1>
-</html>
+<p> Chestnuts are roasted, boiled, <a href='puréed' style='color:#545d62;font-weight:bolder;'>puréed</a> and preserved; used in both sweet and savoury dishes.</p>

0 comments on commit acc0dfc

Please sign in to comment.