diff --git a/lib/json/group_section.py b/lib/json/group_section.py index f9048d52be281b2c18828327c1d683bdbc549cbc..155b9031edcff3fe67f69e62f65b56c4670c70ff 100644 --- a/lib/json/group_section.py +++ b/lib/json/group_section.py @@ -97,8 +97,8 @@ def write_groupfiles_subsection (db, xml, group_guid): wrt.write_tag(xml,4,"autor",owner_name,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"link",wrt.hrefstr(file_link),",") - wrt.write_tag(xml,4,"descricao",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"link",file_link,",") + wrt.write_tag(xml,4,"descricao",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -142,7 +142,7 @@ def write_groupforumtopics_subsection (db, xml, group_guid): wrt.write_tag(xml,4,"autor",owner_name,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"texto",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"texto",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -189,8 +189,8 @@ def write_groupbookmarks_subsection (db, xml, group_guid): wrt.write_tag(xml,4,"autor",owner_name,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"link",wrt.hrefstr(bookmark_link),",") - wrt.write_tag(xml,4,"descricao",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"link",bookmark_link,",") + wrt.write_tag(xml,4,"descricao",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -234,7 +234,7 @@ def write_grouppages_subsection (db, xml, group_guid): wrt.write_tag(xml,4,"autor",owner_name,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"texto",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"texto",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -281,8 +281,8 @@ def write_groupvideos_subsection (db, xml, group_guid): wrt.write_tag(xml,4,"autor",owner_name,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"link",wrt.hrefstr(video_link),",") - wrt.write_tag(xml,4,"descricao",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"link",video_link,",") + wrt.write_tag(xml,4,"descricao",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -350,7 +350,7 @@ def write_groupevents_subsection (db, xml, group_guid): wrt.write_tag(xml,4,"data_inicio",wrt.datestr(time_start),",") wrt.write_tag(xml,4,"data_fim",wrt.datestr(time_end),",") wrt.write_tag(xml,4,"taxa_participacao",fees,",") - wrt.write_tag(xml,4,"descricao",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"descricao",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -393,8 +393,8 @@ def write_groups_section(db, xml_file): wrt.write_tag(xml,2,"proprietario",owner_name,",") wrt.write_tag(xml,2,"titulo",title,",") wrt.write_tag(xml,2,"data",wrt.datestr(time),",") - wrt.write_tag(xml,2,"descricao",wrt.cdata(desc),",") - wrt.write_tag(xml,2,"breve_descricao",wrt.cdata(brief_desc),",") + wrt.write_tag(xml,2,"descricao",wrt.replacebadchars(desc),",") + wrt.write_tag(xml,2,"breve_descricao",wrt.replacebadchars(brief_desc),",") if wrt.groupaccess_permission(db, guid) == 'public': diff --git a/lib/json/user_section.py b/lib/json/user_section.py index 772f20545994c0da369af935b7fe72073ed45115..93cff6619972c143294b2ee781ad2adb7c5c0fc6 100644 --- a/lib/json/user_section.py +++ b/lib/json/user_section.py @@ -149,8 +149,8 @@ def write_userfiles_subsection (db, xml, user_guid): wrt.write_tag(xml,4,"pid",post_attr,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"link",wrt.hrefstr(file_link),",") - wrt.write_tag(xml,4,"descricao",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"link",file_link,",") + wrt.write_tag(xml,4,"descricao",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -188,8 +188,8 @@ def write_userblogs_subsection (db, xml, user_guid): wrt.write_tag(xml,4,"pid",post_attr,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"resumo",wrt.cdata(post_excerpt),",") - wrt.write_tag(xml,4,"texto",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"resumo",wrt.replacebadchars(post_excerpt),",") + wrt.write_tag(xml,4,"texto",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -225,8 +225,8 @@ def write_userbookmarks_subsection (db, xml, user_guid): wrt.write_tag(xml,4,"pid",post_attr,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"link",wrt.hrefstr(bookmark_link),",") - wrt.write_tag(xml,4,"descricao",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"link",bookmark_link,",") + wrt.write_tag(xml,4,"descricao",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -260,7 +260,7 @@ def write_userpages_subsection (db, xml, user_guid): wrt.write_tag(xml,4,"pid",post_attr,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"texto",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"texto",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -283,6 +283,8 @@ def write_uservideos_subsection (db, xml, user_guid): row=0 for (post_guid, post_title, post_desc, time)\ in user_videos: + + row=row+1 # 477 = select * from elgg_metastrings where string='video_url'; video_link=wrt.post_content(db, post_guid, 477) @@ -295,8 +297,8 @@ def write_uservideos_subsection (db, xml, user_guid): wrt.write_tag(xml,4,"pid",post_attr,",") wrt.write_tag(xml,4,"titulo",post_title,",") wrt.write_tag(xml,4,"data",wrt.datestr(time),",") - wrt.write_tag(xml,4,"link",wrt.hrefstr(video_link),",") - wrt.write_tag(xml,4,"descricao",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"link",video_link,",") + wrt.write_tag(xml,4,"descricao",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) @@ -355,7 +357,7 @@ def write_userevents_subsection (db, xml, user_guid): wrt.write_tag(xml,4,"data_inicio",wrt.datestr(time_start),",") wrt.write_tag(xml,4,"data_fim",wrt.datestr(time_end),",") wrt.write_tag(xml,4,"taxa_participacao",fees,",") - wrt.write_tag(xml,4,"descricao",wrt.cdata(post_desc),",") + wrt.write_tag(xml,4,"descricao",wrt.replacebadchars(post_desc),",") wrt.write_comments(db,xml,post_guid) diff --git a/lib/json/write_support_functions.py b/lib/json/write_support_functions.py index 3d6a228e6ab5c1994aa6b1ed764936d6883ccf45..9e5cb3fe91ea6ca50b8ea680381496bd70faf4e9 100644 --- a/lib/json/write_support_functions.py +++ b/lib/json/write_support_functions.py @@ -50,6 +50,11 @@ def lvl (l): return "" #--------------------------------------------------------------------# +#--------------------------------------------------------------------# +def replacebadchars (string): + return "xyz" +#--------------------------------------------------------------------# + #--------------------------------------------------------------------# def cdata (string): cdata_string="<![CDATA["+string+"]]>" @@ -203,7 +208,7 @@ def write_comments (db, xml, post_guid): write_tag(xml,6,"uid",user_attr,",") write_tag(xml,6,"usuario",user_name,",") write_tag(xml,6,"data",datestr(time),",") - write_tag(xml,6,"mensagem",cdata(string),"") + write_tag(xml,6,"mensagem",replacebadchars(string),"") write_close_tag(xml,5,"}",(row < post_comments.rowcount))