GEWIS / PDF-generator-client

0 stars 0 forks source link

Input sanitation for item names #1

Open Yaneriaf opened 8 months ago

Yaneriaf commented 8 months ago

image Items that have a % in their name are not sanitized, meaning that all columns after the name are commented out, resulting in missing numbers. Quite annoying for invoices.

tomudding commented 8 months ago

Do you actually need to sanitise the input? It would make more sense to encode the input to prevent accidentally removing (parts of) the input data. The following character can cause issues (I already added the for LaTeX encoded variant):

    '"' => '{\\textacutedbl}',
    '#' => '\\#',
    '$' => '\\$',
    '%' => '\\%',
    '&' => '\\&',
    '<' => '{\\textlangle}',
    '>' => '{\\textrangle}',
    '\' => '{\\textbackslash}',
    '^' => '\\^{ }',
    '_' => '\\_',
    '{' => '\\{',
    '}' => '\\}',
    '~' => '{\\texttildelow}',
Yaneriaf commented 8 months ago

That would also work I suppose.