Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/metadata/
Date: Fri, 06 Jul 2012 22:19:37
Message-Id: 1341612385.991537a979fb2c3929e8447ec5a5aa9719322629.dywi@gentoo
1 commit: 991537a979fb2c3929e8447ec5a5aa9719322629
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Fri Jul 6 22:06:25 2012 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Fri Jul 6 22:06:25 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=991537a9
7
8 metadata: remove invalid chars "&<>" from values
9
10 modified: roverlay/metadata/abstractnodes.py
11
12 ---
13 roverlay/metadata/abstractnodes.py | 15 +++++++++++++--
14 1 files changed, 13 insertions(+), 2 deletions(-)
15
16 diff --git a/roverlay/metadata/abstractnodes.py b/roverlay/metadata/abstractnodes.py
17 index f5a5c31..9e792e6 100644
18 --- a/roverlay/metadata/abstractnodes.py
19 +++ b/roverlay/metadata/abstractnodes.py
20 @@ -2,11 +2,12 @@
21 # Copyright 2006-2012 Gentoo Foundation
22 # Distributed under the terms of the GNU General Public License v2
23
24 +import re
25 import textwrap
26
27 INDENT = '\t'
28
29 -get_indent = lambda k : k * INDENT
30 +def get_indent ( k ): return k * INDENT
31
32 # -- "abstract" metadata nodes --
33 class _MetadataBasicNode ( object ):
34 @@ -14,6 +15,10 @@ class _MetadataBasicNode ( object ):
35 This is the most basic metadata node that should never be used directly.
36 """
37
38 + # these chars lead to metadata.bad: invalid token
39 + # TODO/FIXME: look into repoman's / portage's source to get _all_ chars
40 + INVALID_CHARS = "&<>"
41 +
42 def __init__ ( self, name, flags ):
43 """Initializes a _MetadataBasicNode.
44
45 @@ -210,7 +215,13 @@ class MetadataLeaf ( _MetadataBasicNode ):
46 width=self.linewidth if hasattr ( self, 'linewidth' ) else 50
47 )
48
49 - val_lines = self._text_wrapper.wrap ( self.value )
50 + val_lines = self._text_wrapper.wrap (
51 + re.sub (
52 + "[{}]".format ( self.__class__.INVALID_CHARS ),
53 + '',
54 + self.value
55 + )
56 + )
57 if len ( val_lines ) < 1:
58 # why?
59 return ""