Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating prod #96

Merged
merged 9 commits into from
Dec 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "use xpyth-parser for parsing xpath (#91)"
This reverts commit e4531f4.
bbonf committed Dec 13, 2023
commit 6298a6693e5356fc93a7ec408ef1bd54b9134572
3 changes: 1 addition & 2 deletions backend/requirements.in
Original file line number Diff line number Diff line change
@@ -11,5 +11,4 @@ alpino-query>=2.1.10
celery[redis]>=5.2.0
mwe-query>=0.0.4
urllib3<=2.0.0
psycopg2
xpyth-parser
psycopg2
11 changes: 2 additions & 9 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -101,9 +101,7 @@ idna==3.4
iniconfig==2.0.0
# via pytest
isodate==0.6.1
# via
# rdflib
# xpyth-parser
# via rdflib
jinja2==3.1.2
# via spacy
kombu==5.3.1
@@ -116,7 +114,6 @@ lxml==4.9.3
# folia
# sastadev
# tei-reader
# xpyth-parser
markupsafe==2.1.3
# via jinja2
murmurhash==1.0.9
@@ -158,9 +155,7 @@ pydantic==2.1.1
pydantic-core==2.4.0
# via pydantic
pyparsing==3.1.1
# via
# rdflib
# xpyth-parser
# via rdflib
pytest==7.4.0
# via
# -r requirements.in
@@ -263,8 +258,6 @@ wcwidth==0.2.6
# via prompt-toolkit
xlsxwriter==3.1.2
# via sastadev
xpyth-parser==0.0.10
# via -r requirements.in

# The following packages are considered to be unsafe in a requirements file:
# setuptools
15 changes: 5 additions & 10 deletions backend/search/basex_search.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
"""Auxiliary functions to facilitate searching in BaseX."""

import lxml.etree
import logging
import string
from io import StringIO
from typing import List
from xpyth_parser.parse import Parser

from .types import BaseXMatch, Result

log = logging.getLogger()

ALLOWED_DBNAME_CHARS = string.ascii_letters + string.digits + \
'!#$%&\'()+-=@[]^_`{}~.'
@@ -18,14 +16,11 @@
def check_xpath(xpath: str) -> bool:
"""Return True if a string is (only) a valid XPath, otherwise False."""
try:
# for some reason ".." isn't being properly parsed. since it's an abbreviation for
# parent::node(), we can replace it ahead of time
Parser(xpath.replace('..', 'parent::node()'), no_resolve=True)
lxml.etree.XPath(xpath)
except lxml.etree.XPathError:
return False
else:
return True
except:
log.exception('XPath parse exception')

return False


def check_db_name(db_name: str) -> bool: