diff --git a/paramecio/citoplasma/httputils.py b/paramecio/citoplasma/httputils.py
index b02c4ee..7a9422d 100644
--- a/paramecio/citoplasma/httputils.py
+++ b/paramecio/citoplasma/httputils.py
@@ -1,6 +1,7 @@
#!/usr/bin/python3
-from bottle import request
+import json, re
+from bottle import request, response
from paramecio.citoplasma.sessions import get_session
from paramecio.citoplasma.keyutils import create_key_encrypt
@@ -19,7 +20,27 @@ except:
no_csrf=False
-
+def filter_ajax(data, filter_tags=True):
+
+ response.set_header('Content-type', 'application/json')
+
+ #arr_data=map(
+
+ json_encoded=json.dumps(data)
+
+ #if filter_tags:
+ # json_encoded=json_encoded.replace('<', '<').replace('>', '>')
+
+ #json_encoded=re.sub(r'\\"', '"', json_encoded)
+
+ #json_encoded=re.sub('\\"', "", json_encoded)
+ #json_encoded=re.sub('\"', """, json_encoded)
+
+ #replace('\\"', '"')
+ #replace('\\\\', '${slashes}').
+
+ return json_encoded
+
class GetPostFiles:
# Need this for obtain utf8 valid values
diff --git a/paramecio/citoplasma/sendmail.py b/paramecio/citoplasma/sendmail.py
index 4df7150..8618c1f 100644
--- a/paramecio/citoplasma/sendmail.py
+++ b/paramecio/citoplasma/sendmail.py
@@ -27,7 +27,7 @@ class SendMail:
self.smtp=smtplib.SMTP(host=self.host, port=self.port)
self.txt_error=''
- def send(self, from_address, to_address, subject, message, content_type='plain', attachments=[]):
+ def send(self, from_address, to_address: list, subject, message, content_type='plain', attachments=[]):
if self.ssl==True:
@@ -106,6 +106,8 @@ class SendMail:
self.smtp.send_message(msg)
+ #self.quit()
+
return True
else:
@@ -161,12 +163,15 @@ class SendMail:
self.smtp.send_message(outer)
+ #self.quit()
+
return True
def quit(self):
self.smtp.quit()
-
+
def __del__(self):
- self.quit()
+ self.smtp.quit()
+
diff --git a/paramecio/citoplasma/templates/utils/list.phtml b/paramecio/citoplasma/templates/utils/list.phtml
index 4fadf69..c508f32 100644
--- a/paramecio/citoplasma/templates/utils/list.phtml
+++ b/paramecio/citoplasma/templates/utils/list.phtml
@@ -42,7 +42,7 @@
% if simplelist.model.fields[field].escape==True:
${simplelist.model.fields[field].show_formatted(row[field])} |
% else:
- ${simplelist.model.fields[field].show_formatted(row[field])|n} |
+ ${str(simplelist.model.fields[field].show_formatted(row[field]))|n} |
% endif
% endfor
diff --git a/paramecio/cromosoma/extrafields/arrayfield.py b/paramecio/cromosoma/extrafields/arrayfield.py
index c5a7827..361d350 100644
--- a/paramecio/cromosoma/extrafields/arrayfield.py
+++ b/paramecio/cromosoma/extrafields/arrayfield.py
@@ -1,4 +1,4 @@
-from paramecio.cromosoma.webmodel import PhangoField
+from paramecio.cromosoma.webmodel import PhangoField,WebModel
import json
class ArrayField(PhangoField):
@@ -33,7 +33,7 @@ class ArrayField(PhangoField):
final_value=json.dumps(value)
- final_value=super().check(final_value)
+ final_value=WebModel.escape_sql(final_value)
return final_value
diff --git a/paramecio/cromosoma/extrafields/dictfield.py b/paramecio/cromosoma/extrafields/dictfield.py
index 63b269d..fac186d 100644
--- a/paramecio/cromosoma/extrafields/dictfield.py
+++ b/paramecio/cromosoma/extrafields/dictfield.py
@@ -1,4 +1,4 @@
-from paramecio.cromosoma.webmodel import PhangoField
+from paramecio.cromosoma.webmodel import WebModel, PhangoField
import json
class DictField(PhangoField):
@@ -18,7 +18,7 @@ class DictField(PhangoField):
value={}
self.error=True
- self.txt_error='Sorry, the json array is invalid'
+ self.txt_error='Sorry, the json dict is invalid'
elif type(value).__name__!='dict':
@@ -26,13 +26,13 @@ class DictField(PhangoField):
self.error=True
self.txt_error='Sorry, the json array is invalid'
- for k,v in enumerate(value):
+ for k,v in value.items():
value[k]=self.field_type.check(v)
final_value=json.dumps(value)
- final_value=super().check(final_value)
+ #final_value=WebModel.escape_sql(final_value)
return final_value
diff --git a/paramecio/cromosoma/extrafields/emailfield.py b/paramecio/cromosoma/extrafields/emailfield.py
index f384593..a94a5da 100644
--- a/paramecio/cromosoma/extrafields/emailfield.py
+++ b/paramecio/cromosoma/extrafields/emailfield.py
@@ -7,6 +7,8 @@ class EmailField(CharField):
def check(self, value):
+ value=super().check(value)
+
self.error=False
self.txt_error=''
@@ -16,4 +18,4 @@ class EmailField(CharField):
value=""
self.txt_error='No valid format'
- return value
\ No newline at end of file
+ return value
diff --git a/paramecio/cromosoma/webmodel.py b/paramecio/cromosoma/webmodel.py
index 22bade3..ed12254 100644
--- a/paramecio/cromosoma/webmodel.py
+++ b/paramecio/cromosoma/webmodel.py
@@ -989,7 +989,7 @@ class PhangoField:
# Property that define if make escape in show_formatted
- self.escape=True
+ self.escape=False
# File related: if the field have a file related, delete the file
@@ -1024,7 +1024,13 @@ class PhangoField:
value=str(value)
- value=WebModel.escape_sql(value)
+ value=value.replace('<', '<')
+
+ value=value.replace('>', '>')
+
+ value=value.replace('"', '"')
+
+ #value=WebModel.escape_sql(value)
if value=="":
self.txt_error="The field is empty"
diff --git a/tests/fieldstest.py b/tests/fieldstest.py
index c716751..fe22f49 100644
--- a/tests/fieldstest.py
+++ b/tests/fieldstest.py
@@ -1,6 +1,7 @@
from settings import config
from paramecio.cromosoma.webmodel import WebModel
from paramecio.cromosoma import corefields
+from paramecio.cromosoma.extrafields.emailfield import EmailField
import unittest
class TestFieldMethods(unittest.TestCase):
@@ -21,7 +22,7 @@ class TestFieldMethods(unittest.TestCase):
value=field.check("injection_'")
- self.assertEqual(value, "injection_\\'")
+ self.assertEqual(value, "injection_'")
def test_integerfield(self):
@@ -40,4 +41,19 @@ class TestFieldMethods(unittest.TestCase):
value=integerfield.check("25'")
self.assertEqual(value, "0")
-
\ No newline at end of file
+
+ def test_emailfield(self):
+
+ emailfield=EmailField('email')
+
+ emailfield.required=True
+
+ emailfield.check('exampleweb-t-sys.com')
+
+ self.assertTrue(emailfield.error)
+
+ emailfield.check('example@web-t-sys.com')
+
+ self.assertFalse(emailfield.error)
+
+
diff --git a/tests/sendmailtest.py b/tests/sendmailtest.py
index 0f87f5f..bdd40cc 100644
--- a/tests/sendmailtest.py
+++ b/tests/sendmailtest.py
@@ -1,5 +1,6 @@
from settings import config
from paramecio.citoplasma import sendmail
+import time
import unittest
class TestFieldMethods(unittest.TestCase):
@@ -8,10 +9,14 @@ class TestFieldMethods(unittest.TestCase):
s=sendmail.SendMail()
- self.assertTrue( s.send(config.portal_email, config.email_test, 'This is a test', 'A message for test a simple email method', content_type='plain', attachments=[]) )
+ self.assertTrue( s.send(config.portal_email, [config.email_test], 'This is a test', 'A message for test a simple email method', content_type='plain', attachments=[]) )
- self.assertTrue( s.send(config.portal_email, config.email_test, 'This is a test', 'A message for test a simple email method in html', content_type='html', attachments=[]) )
+ time.sleep(70)
- self.assertTrue( s.send(config.portal_email, config.email_test, 'This is a test', 'A message for test a simple email method in html and attachments', content_type='html', attachments=['tests/images/image.jpg']) )
+ self.assertTrue( s.send(config.portal_email, [config.email_test], 'This is a test', 'A message for test a simple email method in html', content_type='html', attachments=[]) )
- s.quit()
\ No newline at end of file
+ time.sleep(70)
+
+ self.assertTrue( s.send(config.portal_email, [config.email_test], 'This is a test', 'A message for test a simple email method in html and attachments', content_type='html', attachments=['tests/images/image.jpg']) )
+
+ s.quit()
diff --git a/tests/webmodeltest.py b/tests/webmodeltest.py
index 1bb46b0..01ed771 100644
--- a/tests/webmodeltest.py
+++ b/tests/webmodeltest.py
@@ -79,7 +79,7 @@ class TestWebModelMethods(unittest.TestCase):
print('Select and save in an array')
- self.assertEqual(model.select_to_array(['title', 'content']), {1: {'title': 'Example title Updated', 'content': 'New content Updated'}})
+ self.assertEqual(model.select_to_array(['title', 'content']), [{'id': 1, 'title': 'Example title Updated', 'content': 'New content Updated'}])
model.yes_reset_conditions=True