Commit 4a251671 authored by mitshel's avatar mitshel
Browse files

В выдаче текстовой информации проверяется наличие спецсиволов и их замена (например &, < и т.д.)

parent ef770311
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -107,7 +107,8 @@ def processfile(db,fb2,name,full_path,file,archive=0,file_size=0,cat_id=0):
             cat_id=db.addcattree(rel_path,archive)
          title=''
          lang=''
          annotation='';
          annotation=''
          docdate=''

          if e.lower()=='.fb2' and cfg.FB2PARSE:
             if isinstance(file, str):
@@ -123,6 +124,8 @@ def processfile(db,fb2,name,full_path,file,archive=0,file_size=0,cat_id=0):
                title=fb2.book_title.getvalue()[0].strip(' \'\"\&-.#\\\`')
             if len(fb2.annotation.getvalue())>0:
                annotation=('\n'.join(fb2.annotation.getvalue()))[:10000]
             if len(fb2.docdate.getvalue())>0:
                docdate=fb2.docdate.getvalue()[0].strip();
             
             if VERBOSE:
                if fb2.parse_error!=0:
@@ -131,7 +134,7 @@ def processfile(db,fb2,name,full_path,file,archive=0,file_size=0,cat_id=0):
          if title=='':
             title=n

          book_id=opdsdb.addbook(name,rel_path,cat_id,e,title,annotation,lang,file_size,archive,cfg.DUBLICATES_FIND)
          book_id=opdsdb.addbook(name,rel_path,cat_id,e,title,annotation,docdate,lang,file_size,archive,cfg.DUBLICATES_FIND)
          books_added+=1
          
          if e.lower()=='.fb2' and cfg.FB2PARSE and cfg.COVER_EXTRACT:
+2 −2
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ def websym(s,attr=False):
    """Replace special web-symbols"""
    result = s
    if attr:
        table = {'&':'&amp;','<':'&lt;','"':'\''}
        table = {'"':'\''}
    else:
        table = {'&':'&amp;','<':'&lt;'}
    for k in table.keys():
@@ -175,7 +175,7 @@ def entry_covers(cover,cover_type,book_id):
            enc_print( '<link href="%s?id=%s" rel="x-stanza-cover-image-thumbnail"  type="image/jpeg" />'%(cfg.CGI_PATH,id) )

def entry_content(e_content):
  enc_print('<content type="text">'+e_content+'</content>')
  enc_print('<content type="text">'+websym(e_content)+'</content>')

def entry_finish():
   enc_print('</entry>')
+3 −3
Original line number Diff line number Diff line
@@ -118,15 +118,15 @@ class opdsDatabase:
    cursor.close()
    return book_id

  def addbook(self, name, path, cat_id, exten, title, annotation, lang, size=0, archive=0, doublicates=0):
  def addbook(self, name, path, cat_id, exten, title, annotation, docdate, lang, size=0, archive=0, doublicates=0):
    format=exten[1:]
    format=format.lower()
    if doublicates!=0:
       doublicat=self.finddouble(title,format,size)
    else:
       doublicat=0
    sql_addbook=("insert into "+TBL_BOOKS+"(filename,path,cat_id,filesize,format,title,annotation,lang,cat_type,doublicat,avail) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, 2)")
    data_addbook=(name,path,cat_id,size,format,title,annotation,lang,archive,doublicat)
    sql_addbook=("insert into "+TBL_BOOKS+"(filename,path,cat_id,filesize,format,title,annotation,docdate,lang,cat_type,doublicat,avail) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, 2)")
    data_addbook=(name,path,cat_id,size,format,title,annotation,docdate,lang,archive,doublicat)
    cursor=self.cnx.cursor()
    cursor.execute(sql_addbook,data_addbook)
    book_id=cursor.lastrowid
Loading