From f8f9d5d1b6959362071e41d9ebc102cc600db153 Mon Sep 17 00:00:00 2001 From: Bruno Nocera Zanette <brunonzanette@gmail.com> Date: Thu, 12 Sep 2013 16:40:37 -0300 Subject: [PATCH] Fix HREF Strings Fixed IDs strings. HREF strings were being written with XML style, for example: "link":" href="xyz"" instead of "link":"xyz" Signed-off-by: Bruno Nocera Zanette <brunonzanette@gmail.com> --- lib/json/group_section.py | 22 +++++++++++----------- lib/json/user_section.py | 22 ++++++++++++---------- lib/json/write_support_functions.py | 7 ++++++- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/lib/json/group_section.py b/lib/json/group_section.py index f9048d5..155b903 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 772f205..93cff66 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 3d6a228..9e5cb3f 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)) -- GitLab