Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1A2E49C14 for ; Thu, 16 May 2013 22:29:54 +0000 (UTC) Received: (qmail 46099 invoked by uid 500); 16 May 2013 22:29:54 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 46045 invoked by uid 500); 16 May 2013 22:29:54 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 44951 invoked by uid 99); 16 May 2013 22:29:53 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 May 2013 22:29:53 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1CC2E15D34; Thu, 16 May 2013 22:29:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brondsem@apache.org To: allura-commits@incubator.apache.org Date: Thu, 16 May 2013 22:30:31 -0000 Message-Id: <79bd7b0e553f43b49e50574d74d42f18@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [40/50] [abbrv] git commit: [#5634] ticket:333 Use h.really_unicode and add comments [#5634] ticket:333 Use h.really_unicode and add comments Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/fcd3b587 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/fcd3b587 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/fcd3b587 Branch: refs/heads/db/6208 Commit: fcd3b5876e810c4d269daf0844d848b420b04237 Parents: 9224324 Author: Igor Bondarenko Authored: Wed May 8 14:10:17 2013 +0000 Committer: Dave Brondsema Committed: Wed May 15 15:44:04 2013 +0000 ---------------------------------------------------------------------- Allura/allura/lib/markdown_extensions.py | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fcd3b587/Allura/allura/lib/markdown_extensions.py ---------------------------------------------------------------------- diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py index 62b7fe9..a1158e5 100644 --- a/Allura/allura/lib/markdown_extensions.py +++ b/Allura/allura/lib/markdown_extensions.py @@ -252,7 +252,15 @@ class RelativeLinkRewriter(markdown.postprocessors.Postprocessor): rewrite(link, 'href') for link in soup.findAll('img'): rewrite(link, 'src') - return unicode(str(soup), "utf-8" ) + # BeautifulSoup always stores data in unicode, + # but when doing unicode(soup) it does some strange things + # like nesting html comments, e.g. returns --> + # instead of . + # Converting soup object to string representation first, + # and then back to unicode avoids that. + # str() called on BeautifulSoup document always returns string + # encoded in utf-8, so this should always work. + return h.really_unicode(str(soup)) def _rewrite(self, tag, attr): val = tag.get(attr)