git://git.onelab.eu
/
sface.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ce4c16b
)
fix failed parsing of attributes with spaces in them in xml viewer
author
smbaker
<smbaker@fc8clean.lan>
Mon, 13 Jun 2011 23:21:35 +0000
(16:21 -0700)
committer
smbaker
<smbaker@fc8clean.lan>
Mon, 13 Jun 2011 23:21:35 +0000
(16:21 -0700)
sface/xmlwidget.py
patch
|
blob
|
history
diff --git
a/sface/xmlwidget.py
b/sface/xmlwidget.py
index
a803868
..
be53182
100644
(file)
--- a/
sface/xmlwidget.py
+++ b/
sface/xmlwidget.py
@@
-1,4
+1,5
@@
import os
import os
+import shlex
import sys
from PyQt4.QtCore import *
import sys
from PyQt4.QtCore import *
@@
-277,11
+278,21
@@
class ElemNodeDelegate(QAbstractItemDelegate):
AttListHtml = ''
if len(tmp) > 1:
# many elems don't have atts...
AttListHtml = ''
if len(tmp) > 1:
# many elems don't have atts...
- attList = tmp[1].split()
+ # use shlex.split so we can handle quoted strings with spaces
+ # in them, like <link enpoints="foo bar">. Note that there are
+ # documented problems with shlex.split and unicode, so we
+ # convert any potential unicode to a string first.
+ attList = shlex.split(str(tmp[1]))
for att in attList:
for att in attList:
- tmp = att.split('=')
- attName = tmp[0]
- attValue = tmp[1][1:-1]
+ tmp = att.split('=',1)
+ if len(tmp)>=2:
+ attName = tmp[0]
+ attValue = tmp[1]
+ else:
+ # this shouldn't happen, but if it does, pretend the
+ # attribute value is blank.
+ attName = tmp[0]
+ attValue = ""
AttListHtml += (nonHighAttPattern % (attName, attValue))
html = (globPattern % (elemName, AttListHtml))
return html
AttListHtml += (nonHighAttPattern % (attName, attValue))
html = (globPattern % (elemName, AttListHtml))
return html