Closed GoogleCodeExporter closed 9 years ago
yes it's a known trouble ...
I always wanted to disable users to enter text tag with simple quote (but
never did
it) ... because they should be escaped in xpath query to work properly, and
never
take the time to escape them ...
Original comment by manat...@gmail.com
on 8 Jan 2009 at 1:32
What about photo collections where tags were added before using a tool which
did not
have such a limitation? Isn't there another way than disabling quotes? French
and
English both use quotes extensively...
Original comment by davito...@gmail.com
on 8 Jan 2009 at 4:03
@davitofrg
I don't, and NEVER, disabled quotes, for the reasons you said ....
I took about escaping quotes in xpath ...
If anybody out there reach to make this lines works :
-------------------------------------------------------------------------------
#!/usr/bin/env python
from lxml.etree import fromstring,Element
def escape(x):
x=x.replace("'","\'") # here is the work !!!!
return x
def test(val):
print "test",val
xml = fromstring("""<root/>""")
xml.append( Element("a",{"key":val}) )
assert len(xml.xpath("""//a[@key='%s']"""%escape(val)))==1
test("""value""")
test("""&""")
test("""<""")
test(""">""")
test(""""""")
test("'")
test('"')
-------------------------------------------------------------------------------
(try to modify escape method, to let the tests pass)
then it should be possible to jbrout to handle tags with quotes ...
Original comment by manat...@gmail.com
on 8 Jan 2009 at 5:31
fixed in rev 148 ...
now tags can contain any chars, and it should't crash jbrout
Original comment by manat...@gmail.com
on 8 Jan 2009 at 9:17
Original issue reported on code.google.com by
gautier....@gmail.com
on 8 Jan 2009 at 1:24