Date: Tue, 08 Jun 2010 23:47:38 +0000 From: Anonymous <swell.k@gmail.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/147706: [patch][maintainer] www/rssdler: make xmlUnEscape and percentUnQuote case-insensitive Message-ID: <86iq5t5bol.fsf@gmail.com> Resent-Message-ID: <201006082350.o58No160046200@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 147706 >Category: ports >Synopsis: [patch][maintainer] www/rssdler: make xmlUnEscape and percentUnQuote case-insensitive >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jun 08 23:50:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Anonymous >Release: FreeBSD 9.0-CURRENT amd64 >Organization: >Environment: >Description: See Issue#55 on googlecode. Unlike S.replace() and urllib.unquote() this version can handle mixed case, e.g. %Ab or %aB. Reason: About 2 months passed with this trivial issue unresolved. I guess upstream maintainer is inactive. >How-To-Repeat: before >>> xmlUnEscape(percentUnQuote('%20%5bfoo & bar%5d%20')) u' %5bfoo & bar%5d ' >>> unQuoteReQuote('%20%5bfoo & bar%5d%20') u'%20%255bfoo%20%26AMP; bar%5d ' after >>> xmlUnEscape(percentUnQuote('%20%5bfoo & bar%5d%20')) u' [foo & bar] ' >>> unQuoteReQuote('%20%5bfoo & bar%5d%20') u'%20%5Bfoo%20%26%20bar%5D%20' >Fix: --- a.diff begins here --- Index: www/rssdler/files/patch-percentUnQuote =================================================================== RCS file: www/rssdler/files/patch-percentUnQuote diff -N www/rssdler/files/patch-percentUnQuote --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ www/rssdler/files/patch-percentUnQuote 8 Jun 2010 22:41:07 -0000 @@ -0,0 +1,16 @@ +Index: rssdler.py +=================================================================== +--- rssdler.py (revision 169) ++++ rssdler.py (working copy) +@@ -363,9 +363,9 @@ def percentUnQuote( sStr, p=percentunQuoteDict, re + replaced in order of the sequence""" + for search in p: + if search in reserved: continue +- sStr = sStr.replace( search, p[search] ) ++ sStr = re.sub('(?i)' + re.escape(search), p[search], sStr) + for search in reserved: +- sStr = sStr.replace( search, p[search]) ++ sStr = re.sub('(?i)' + re.escape(search), p[search], sStr) + return sStr + + def percentQuote(sStr, urlPart=(2,), pd=percentQuoteDict): Index: www/rssdler/files/patch-xmlUnEscape =================================================================== RCS file: www/rssdler/files/patch-xmlUnEscape diff -N www/rssdler/files/patch-xmlUnEscape --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ www/rssdler/files/patch-xmlUnEscape 8 Jun 2010 22:40:49 -0000 @@ -0,0 +1,32 @@ +Index: rssdler.py +=================================================================== +--- rssdler.py (revision 169) ++++ rssdler.py (working copy) +@@ -79,6 +79,7 @@ percentQuoteDict = {u'!': u'%21', u' ': u'%20', u' + u';': u'%3B', u':': u'%3A', u']': u'%5D', u'[': u'%5B', u'?': u'%3F', + u'!':u'%7E'} + percentunQuoteDict = dict(((j,i) for (i,j) in percentQuoteDict.items())) ++xmlUnEscapeDict = { u'<' : u'<', u'>' : u'>', u'&' : u'&' } + netscapeHeader= """# HTTP Cookie File + # http://www.netscape.com/newsref/std/cookie_spec.html + # This is a generated file! Do not edit.\n\n""" +@@ -327,16 +328,15 @@ def unicodeC( s ): + raise UnicodeEncodeError(u'could not encode %s to unicode' % s) + return s + +-def xmlUnEscape( sStr, percent=0, pd=percentunQuoteDict ): ++def xmlUnEscape( sStr, percent=0, pd=percentunQuoteDict, xd=xmlUnEscapeDict ): + u"""xml unescape a string, by default also checking for percent encoded + characters. set percent=0 to ignore percent encoding. + can specify your own percent quote dict + (key, value) pairs are of (search, replace) ordering with percentunQuoteDict + """ +- sStr = sStr.replace("<", "<") +- sStr = sStr.replace(">", ">") + if percent: sStr = percentUnQuote( sStr, pd ) +- sStr = sStr.replace("&", "&") ++ for search in xd: ++ sStr = re.sub('(?i)' + re.escape(search), xd[search], sStr) + return sStr + + def percentIsQuoted(sStr, testCases=percentQuoteDict.values()): --- a.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86iq5t5bol.fsf>