brunolojor / jbrout

Automatically exported from code.google.com/p/jbrout
0 stars 0 forks source link

Tags with ' #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a tag [Hélène Guiavarc'h] (kenavo!)
2. Search Hélène Guivarc'h and brad pitt
3.

What is the expected output? What do you see instead?
Photos with Hélèn eand brad Pitt
Traceback (most recent call last):
   File "jbrout.py", line 2902, in on_btn_search_clicked
    ln = JBrout.db.select(xpath)
   File "jbrout/jbrout/db.py", line 227, in select
   File "lxml.etree.pyx", line 1323, in lxml.etree._Element.xpath
(src/lxml/lxml.etree.c:12995)
   File "xpath.pxi", line 283, in lxml.etree.XPathElementEvaluator.__call__
(src/lxml/lxml.etree.c:85844)
   File "xpath.pxi", line 205, in
lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:85274)
   File "xpath.pxi", line 190, in
lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:85109)
 XPathEvalError: Invalid predicate

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by gautier....@gmail.com on 8 Jan 2009 at 1:24

GoogleCodeExporter commented 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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
@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

GoogleCodeExporter commented 9 years ago
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