f-klubben / stregsystemet

The very public stregsystem repo
Other
38 stars 49 forks source link

[Bug fix] Sanitize csv mails #453

Closed Mast3rwaf1z closed 4 months ago

Mast3rwaf1z commented 4 months ago

in progress fix to unsanitized values in csv files, there are two issues atm

Mast3rwaf1z commented 4 months ago

What about products with " in the name

Hmm good point, i'll just have a google to see how others solve that as well, no way we have to consider everything :P

I have tested it using mailhog like in #434, mailhog --smtp-bind-addr 0.0.0.0:25 and this python script:

import csv
with open("Downloads/sales.csv") as file:
    reader = csv.reader(file)
    for row in reader:
        print(row)

the two issues i've mentioned is gone now at least

Mast3rwaf1z commented 4 months ago

What about products with " in the name

@krestenlaust this should be covered now

Mast3rwaf1z commented 4 months ago

I have an alternative idea that i just tested, instead of having the rows_to_csv function we have now, we can go with your idea of using the csv library and mock a file class:

import csv
class fakefile:
    data = ""
    def write(self, data):
        self.data += data

def rows_to_csv(rows):
    file = fakefile()
    writer = csv.writer(file)
    writer.writerows(rows)
    return file.data