CVE-2024-27291 (Python, published 2024-03-21T02:52Z)
Description: value: Docassemble is an expert system for guided interviews and document assembly. Prior to 1.4.97, it is possible to create a URL that acts as an open redirect. The vulnerability has been patched in version 1.4.97 of the master branch.
Severity: nan (CVSS v3 base score: )
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/jhpyle/docassemble
Files changed:
CHANGELOG.md
Dockerfile
docassemble_base/docassemble/base/data/sources/base-words.yml
docassemble_base/docassemble/base/error.py
docassemble_base/docassemble/base/pandoc.py
docassemble_base/docassemble/base/parse.py
docassemble_base/docassemble/base/pdftk.py
docassemble_webapp/docassemble/webapp/develop.py
docassemble_webapp/docassemble/webapp/server.py
docassemble_webapp/docassemble/webapp/users/forms.py
docassemble_webapp/docassemble/webapp/validators.py
Commit message: fixed security issues; added pdftk option; added development site is protected Configuration directive; altered error message display so that end users will not see certain types of error messages, but they will be displayed in the log


Vulnerable code:
&& unzip -o omw-1.4.zip"
import convertapi
import requests
from pikepdf import Pdf
from docassemble.base.error import DAError, DANotFoundError, MandatoryQuestion, DAErrorNoEndpoint, DAErrorMissingVariable, ForcedNameError, QuestionError, ResponseError, BackgroundResponseError, BackgroundResponseActionError, CommandError, CodeExecute, DAValidationError, ForcedReRun, LazyNameError, DAAttributeError, DAIndexError, DAException, DANameError
            raise DAError("A block must be in the form of a dictionary." + self.idebug(orig_data))
            raise DAError(orig_data['__error__'])
            raise DAError("There can only be one directive in a question.  You had more than one.\nThe directives are yesno, noyes, yesnomaybe, noyesmaybe, fields, buttons, choices, dropdown, combobox, signature, and review" + self.idebug(data))
            raise DAError("This block is missing a 'question' directive." + self.idebug(data))
                raise DAError("A features section must be a dictionary." + self.idebug(data))
                    raise DAError("Table width in features must be an integer." + self.idebug(data))
                    raise DAError("progress bar multiplier in features must be between 0 and 1." + self.idebug(data))
                    raise DAError("A features section checkin interval entry must be an integer." + self.idebug(data))
                    raise DAError("A features section checkin interval entry must be at least 1000, if not 0." + self.idebug(data))
                        raise DAError("A features section " + key + " entry must be a list or plain text." + self.idebug(data))
                        raise DAError("A features section " + key + " entry must be plain text." + self.idebug(data))
                        raise DAError("The " + key + " in features did not contain a valid date." + self.idebug(data))
                raise DAError("An only sets phrase must be text or a list." + self.idebug(data))
            raise DAError("A block can be a question block or a code block but cannot be both at the same time." + self.idebug(data))
                raise DAError("The 'event' designator is for special screens that do not gather information and can only be used with 'buttons' or with no other controls." + self.idebug(data))
                raise DAError("A 'translations' block must be a list" + self.idebug(data))
                    raise DAError("A 'translations' block must be a list of text items" + self.idebug(data))
                    raise DAError("Invalid translations entry '" + item + "'.  A translations entry must refer to a file ending in .xlsx, .xlf, or .xliff." + self.idebug(data))
                    raise DAError("Invalid translations entry: " + item + ".  A translations entry must refer to a data sources file" + self.idebug(data))
                raise DAError("An on change block must be a dictionary." + self.idebug(data))
                raise DAError("An on change block must not contain any other keys." + self.idebug(data))
                    raise DAError("An on change block must be a dictionary where the keys are field names and the values are Python code." + self.idebug(data))
                raise DAError("A sections list must be a list." + self.idebug(data))
                raise DAError("A progressive directive can only be used with sections." + self.idebug(data))
                raise DAError("A progressive directive can only be true or false." + self.idebug(data))
                raise DAError("An auto open directive can only be used with sections." + self.idebug(data))
                raise DAError("An auto open directive can only be true or false." + self.idebug(data))
                raise DAError("Invalid machine learning storage entry '" + str(data['machine learning storage']) + ".'  A machine learning storage entry must refer to a file ending in .json." + self.idebug(data))
                raise DAError("Invalid machine learning storage entry: " + str(data['machine learning storage']) + self.idebug(data))
                        raise DAError("When allowed to set is a list, it must be a list of text items." + self.idebug(data))
                raise DAError("When allowed to set is not a list, it must be plain text." + self.idebug(data))
                    raise DAError("A usedefs section must consist of a list of strings or a single string." + self.idebug(data))
                    raise DAError('Referred to a non-existent def "' + usedef + '."  All defs must be defined before they are used.' + self.idebug(data))
                raise DAError("You can only set the section from a question." + self.idebug(data))
                raise DAError("You cannot set a continue button label if the type of question is yesno, noyes, yesnomaybe, noyesmaybe, or buttons." + self.idebug(data))
                raise DAError("You cannot set a resume button label if the type of question is not review." + self.idebug(data))
                raise DAError("You cannot set the skip undefined directive if the type of question is not review." + self.idebug(data))
                raise DAError("You cannot set list collect without a fields specifier." + self.idebug(data))
                raise DAError("Invalid data under list collect." + self.idebug(data))
                raise DAError("You cannot use the mandatory modifier and the initial modifier at the same time." + self.idebug(data))
                raise DAError("You cannot use the mandatory modifier on this type of block." + self.idebug(data))
                    raise DAError("An attachment option must a dictionary." + self.idebug(data))
                                raise DAError('An initial yaml file must be a string.' + self.idebug(data))
                                raise DAError('An additional yaml file must be a string.' + self.idebug(data))
                            raise DAError('The template file must be a string.' + self.idebug(data))
                            raise DAError('The rtf template file must be a string.' + self.idebug(data))
                            raise DAError('The docx reference file must be a string.' + self.idebug(data))
                raise DAError("A script section must be plain text." + self.idebug(data))
                raise DAError("A css section must be plain text." + self.idebug(data))
            raise DAError("Only a code block can be marked as initial." + self.idebug(data))
                    raise DAError("An objects section cannot contain a nested list." + self.idebug(data))
                raise DAError("A data block variable name must be plain text." + self.idebug(data))
                raise DAError("A data from code block variable name must be plain text." + self.idebug(data))
                # raise DAError("An objects section must be organized as a list." + self.idebug(data))
                    raise DAError("An objects section cannot contain a nested list." + self.idebug(data))
            #     raise DAError("The id " + str(data['id']) + " is already in use by another block.  Id names must be unique." + self.idebug(data))
                raise DAError("A 'ga id' must refer to text." + self.idebug(data))
                raise DAError("A 'segment id' must refer to text." + self.idebug(data))
                raise DAError("A 'segment' must refer to a dictionary." + self.idebug(data))
                    raise DAError("An 'id' under 'segment' must refer to text." + self.idebug(data))
                    raise DAError("An 'arguments' under 'segment' must refer to a dictionary." + self.idebug(data))
                        raise DAError("Each item under 'arguments' in a 'segment' must be plain text." + self.idebug(data))
                raise DAError("An 'order' block cannot be combined with another type of block." + self.idebug(data))
                raise DAError("An 'order' block must be a list." + self.idebug(data))
                raise DAError("The '" + key + "' section needs to be a dictionary, not a list or text." + self.idebug(data))
                        raise DAError("Each item in the 'image sets' section needs to be a dictionary, not a list.  Each dictionary item should have an 'images' definition (which can be a dictionary or list) and an optional 'attribution' definition (which must be text)." + self.idebug(data))
                    raise DAError("Each item in the 'images' section needs to be a dictionary, not a list." + self.idebug(data))
                        raise DAError("An attribution in an 'image set' section cannot be a dictionary or a list." + self.idebug(data))
                            raise DAError("An 'images' definition in an 'image set' item must be a dictionary or a list." + self.idebug(data))
                        raise DAError("An 'images' section must be a dictionary or a list." + self.idebug(data))
                raise DAError("A def name must be a string." + self.idebug(data))
                    raise DAError("A mako template definition must be a string or a list of strings." + self.idebug(data))
                        raise DAError("A mako template definition must be a string." + self.idebug(data))
                raise DAError("An interview help section must not be in the form of a list." + self.idebug(data))
                        raise DAError("An interview help audio section must be in the form of a text item or a list of text items." + self.idebug(data))
                        raise DAError("An interview help video section must be in the form of a text item or a list of text items." + self.idebug(data))
                    raise DAError("A heading within an interview help section must be text, not a list or a dictionary." + self.idebug(data))
                    raise DAError("Help content must be text, not a list or a dictionary." + self.idebug(data))
                raise DAError("No content section was found in an interview help section." + self.idebug(data))
                    raise DAError("Help label must be text, not a list or a dictionary." + self.idebug(data))
                raise DAError("A default screen parts block must be in the form of a dictionary." + self.idebug(data))
                        raise DAError("A default screen parts block must be a dictionary of text keys and text values." + self.idebug(data))
                raise DAError("A default validation messages block must be in the form of a dictionary." + self.idebug(data))
                    raise DAError("A validation messages block must be a dictionary of text keys and text values." + self.idebug(data))
                    raise DAError("A metadata directive cannot be mixed with other directives." + self.idebug(data))
                raise DAError("A metadata section must be organized as a dictionary." + self.idebug(data))
                raise DAError("A modules section must be organized as a list." + self.idebug(data))
                raise DAError("A reset section must be organized as a list." + self.idebug(data))
                raise DAError("An imports section must be organized as a list." + self.idebug(data))
                raise DAError("Terms must be organized as a dictionary or a list." + self.idebug(data))
                    raise DAError("A terms section organized as a list must be a list of dictionary items." + self.idebug(data))
                raise DAError("Terms must be organized as a dictionary or a list." + self.idebug(data))
                    raise DAError("A terms section organized as a list must be a list of dictionary items." + self.idebug(data))
                        raise DAError("A terms section organized as a list must be a list of dictionary items." + self.idebug(data))
                raise DAError("A terms section must be organized as a dictionary or a list." + self.idebug(data))
                        raise DAError("An auto terms section organized as a list must be a list of dictionary items." + self.idebug(data))
                raise DAError("An auto terms section must be organized as a dictionary or a list." + self.idebug(data))
                raise DAError("A default role must be a list or a string." + self.idebug(data))
                raise DAError("The role of a question must be a string or a list." + self.idebug(data))
                        raise DAError('An include section could not find the file ' + str(questionPath) + '.' + self.idebug(data))
                raise DAError("An include section must be organized as a list." + self.idebug(data))
                    raise DAError("An action buttons specifier must be a list." + self.idebug(data))
                        raise DAError("An action buttons item must be a dictionary." + self.idebug(data))
                        raise DAError("An action buttons item must contain an action in plain text." + self.idebug(data))
                        raise DAError("The new window specifier in an action buttons item must refer to True or plain text." + self.idebug(data))
                        raise DAError("The arguments specifier in an action buttons item must refer to a dictionary." + self.idebug(data))
                        raise DAError("An action buttons item must contain a label in plain text." + self.idebug(data))
                        raise DAError("The color specifier in an action buttons item must refer to plain text." + self.idebug(data))
                        raise DAError("The icon specifier in an action buttons item must refer to plain text." + self.idebug(data))
                        raise DAError("The placement specifier in an action buttons item must refer to plain text." + self.idebug(data))
                        raise DAError("The css classifier specifier in an action buttons item must refer to plain text." + self.idebug(data))
                        raise DAError("The forget prior specifier in an action buttons item must refer to true or false." + self.idebug(data))
                            raise DAError("The arguments specifier in an action buttons item must refer to plain items." + self.idebug(data))
                raise DAError("An if statement must either be text or a list." + self.idebug(data))
                raise DAError("A validation code statement must be text." + self.idebug(data))
                        raise DAError("The orelse part of a require section must be organized as a dictionary." + self.idebug(data))
                    raise DAError("A require section must have an orelse part." + self.idebug(data))
                raise DAError("A require section must be organized as a list." + self.idebug(data))
        #         raise DAError("A role section must be text or a list." + self.idebug(data))
                raise DAError("A css class can only accompany a question." + self.idebug(data))
                raise DAError("A table css class can only accompany a question." + self.idebug(data))
                                raise DAError("An audio declaration in a help block can only contain a text item or a list of text items." + self.idebug(data))
                                raise DAError("A video declaration in a help block can only contain a text item or a list of text items." + self.idebug(data))
                            raise DAError("A content declaration in a help block can only contain text." + self.idebug(data))
                    raise DAError("An audio declaration can only contain a text item or a list of text items." + self.idebug(data))
                    raise DAError("A video declaration can only contain a text item or a list of text items." + self.idebug(data))
            raise DAError("The required modifier can only be used on a signature block" + self.idebug(data))
                raise DAError("A check in event must be text or a list." + self.idebug(data))
                raise DAError("A yesno must refer to text." + self.idebug(data))
                raise DAError("A noyes must refer to text." + self.idebug(data))
                raise DAError("A yesnomaybe must refer to text." + self.idebug(data))
                raise DAError("A noyesmaybe must refer to text." + self.idebug(data))
                raise DAError("A sets phrase must be text or a list." + self.idebug(data))
                raise DAError("An event phrase must be text or a list." + self.idebug(data))
                    raise DAError("Missing or invalid variable name " + repr(data['field']) + "." + self.idebug(data))
                        raise DAError("Missing or invalid variable name " + repr(data['continue button field']) + "." + self.idebug(data))
                    raise DAError("A validation messages indicator must be a dictionary." + self.idebug(data))
                        raise DAError("A validation messages indicator must be a dictionary of text keys and text values." + self.idebug(data))
                raise DAError("A continue button field must be plain text." + self.idebug(data))
                raise DAError("A need phrase must be text or a list." + self.idebug(data))
                        raise DAError("If 'need' contains a dictionary it can only include keys 'pre' or 'post'." + self.idebug(data))
                            raise DAError("A need post phrase must be text or a list." + self.idebug(data))
                            raise DAError("A need pre phrase must be text or a list." + self.idebug(data))
                    raise DAError("In 'need', the items must be text strings." + self.idebug(data))
                raise DAError("The target of a template must be plain text." + self.idebug(data))
                raise DAError("A target directive can only be used with a template." + self.idebug(data))
                raise DAError("A table definition must have definitions for table, row, and column." + self.idebug(data))
                raise DAError("The row part of a table definition must be plain Python code." + self.idebug(data))
                raise DAError("The column part of a table definition must be a list." + self.idebug(data))
                    raise DAError("The column items in a table definition must be dictionaries." + self.idebug(data))
                    raise DAError("A column item in a table definition cannot be empty." + self.idebug(data))
                        raise DAError("The edit directive must be a list of attributes, or True or False" + self.idebug(data))
                            raise DAError("The edit directive must be a list of attribute names" + self.idebug(data))
                    raise DAError("The edit directive must be a list of attributes, or True or False" + self.idebug(data))
                        raise DAError("The read only directive must be plain text referring to an attribute" + self.idebug(data))
                        raise DAError("The edit header directive must be text" + self.idebug(data))
                        raise DAError("The read only directive must be plain text referring to an attribute" + self.idebug(data))
                        raise DAError("The edit header directive must be text" + self.idebug(data))
                    raise DAError('A content file must be specified as text, as a list of text filenames, or as a dictionary with code as the key' + self.idebug(data))
                        raise DAError('A content file must be specified as text, as a list of text filenames, or as a dictionary with code as the key' + self.idebug(data))
                    #    raise DAError('The content file ' + str(data['content file']) + ' is not a markdown file ' + str(file_to_read) + self.idebug(data))
                        raise DAError('Unable to read content file ' + str(data['content file']) + ' after trying to find it at ' + str(file_to_read) + self.idebug(data))
                raise DAError("A template must designate a single variable expressed as text." + self.idebug(data))
                raise DAError("The content of a template must be expressed as text." + self.idebug(data))
                raise DAError("A code section must be text, not a list or a dictionary." + self.idebug(data))
            #    raise DAError("A reconsider directive must be true or false." + self.idebug(data))
                    raise DAError("A reconsider directive must be true, false, a single variable or a list." + self.idebug(data))
                        raise DAError("A reconsider directive must refer to variable names expressed as text." + self.idebug(data))
                raise DAError("A undefine directive must a single variable or a list." + self.idebug(data))
                    raise DAError("A undefine directive must refer to variable names expressed as text." + self.idebug(data))
                raise DAError("A continue button field must be plain text." + self.idebug(data))
                raise DAError("The fields must be written in the form of a list." + self.idebug(data))
                    raise DAError("Each individual field in a list of fields must be expressed as a dictionary item, e.g., ' - Fruit: user.favorite_fruit'." + self.idebug(data))
                        raise DAError("Invalid datatype of hidden field." + self.idebug(data))
                        raise DAError("A multiple choice field must refer to a list of choices." + self.idebug(data))
                            raise DAError("An ajax field must have an associated action." + self.idebug(data))
                            raise DAError("An ajax field cannot contain a list of choices except through an action." + self.idebug(data))
                        raise DAError("A multiple choice field must refer to a list of choices." + self.idebug(data))
                    raise DAError("An object labeler can only be used with an object data type")
                    raise DAError("You cannot combine note, html, and/or raw html in a single field." + self.idebug(data))
                            raise DAError("A validation messages indicator must be a dictionary." + self.idebug(data))
                                raise DAError("A validation messages indicator must be a dictionary of text keys and text values." + self.idebug(data))
                                    raise DAError("An allow privileges specifier must be a list of plain text items or code." + self.idebug(data))
                            raise DAError("An allow privileges specifier must be a list of plain text items or code." + self.idebug(data))
                                    raise DAError("An allow users specifier must be a list of integers and plain text items or code." + self.idebug(data))
                            raise DAError("An allow users specifier must be a list of integers and plain text items or code." + self.idebug(data))
                            raise DAError("A js show if or js hide if expression must be a string" + self.idebug(data))
                            raise DAError("A js disable if or js enable if expression must be a string" + self.idebug(data))
                                        raise DAError(key + " cannot be combined with " + other_key)
                                    raise DAError("You cannot mix js show if and non-js show if" + self.idebug(data))
                                    raise DAError("You cannot mix js disable if and non-js show if" + self.idebug(data))
                                raise DAError("The keys of '" + key + "' must be 'variable' and 'is,' or 'code.'" + self.idebug(data))
                            raise DAError("The keys of '" + key + "' cannot be a list" + self.idebug(data))
                            raise DAError("Invalid variable name in show if/hide if")
                                        raise DAError(key + " cannot be combined with " + other_key)
                                    raise DAError("You cannot mix js show if and non-js disable if" + self.idebug(data))
                                    raise DAError("You cannot mix js disable if and non-js disable if" + self.idebug(data))
                                raise DAError("The keys of '" + key + "' must be 'variable' and 'is,' or 'code.'" + self.idebug(data))
                            raise DAError("The keys of '" + key + "' cannot be a list" + self.idebug(data))
                            raise DAError("Invalid variable name in " + key)
                            raise DAError("A 'disable others' directive cannot be used with this data type." + self.idebug(data))
                            raise DAError("A 'disable others' directive must be True, False, or a list of variable names." + self.idebug(data))
                            raise DAError("An 'uncheck others' directive must be True, False, or a list of variable names." + self.idebug(data))
                            raise DAError("A 'check others' directive must be True, False, or a list of variable names." + self.idebug(data))
                            raise DAError("If the datatype of a field is 'range', you must provide a min and a max." + self.idebug(data))
                                raise DAError("An exclude entry cannot be a dictionary." + self.idebug(data))
                            raise DAError("address autocomplete must be a Python expression, a dictionary, or a boolean value." + self.idebug(data))
                            raise DAError(key + " is not in the correct format." + self.idebug(data))
                                raise DAError(key + " has an invalid key " + repr(item) + "." + self.idebug(data))
                            raise DAError(key + ' must specify a width.' + self.idebug(data))
                                    raise DAError(key + " " + subkey + " must be a number between 1 and 12, or a Python expression." + self.idebug(data))
                                    raise DAError(key + " " + subkey + " must be True or False, or a Python expression." + self.idebug(data))
                            raise DAError(key + " is not in the correct format." + self.idebug(data))
                                raise DAError(key + " has an invalid key " + repr(item) + "." + self.idebug(data))
                            raise DAError(key + ' must specify a width.' + self.idebug(data))
                            raise DAError(key + " width must be a number between 1 and 12, or a Python expression." + self.idebug(data))
                            raise DAError("An action must be plain text" + self.idebug(data))
                            raise DAError("A trigger at must an integer greater than one" + self.idebug(data))
                                raise DAError("choices is not in appropriate format" + self.idebug(data))
                                raise DAError("An exclude entry cannot be a dictionary." + self.idebug(data))
                            raise DAError("If you use 'field' to indicate a variable in a 'fields' section, you must also include a 'label.'" + self.idebug(data))
                            raise DAError("Fields in a 'field' section must be plain text." + self.idebug(data))
                            raise DAError("Missing or invalid variable name " + repr(field[key]) + "." + self.idebug(data))
                            raise DAError("If you use 'label' to label a field in a 'fields' section, you must also include a 'field.'" + self.idebug(data))
                            raise DAError("Syntax error: field label '" + str(key) + "' overwrites previous label, '" + str(field_info['label'].original_text) + "'" + self.idebug(data))
                            raise DAError("Fields in a 'field' section must be plain text." + self.idebug(data))
                            raise DAError("Missing or invalid variable name " + repr(field[key]) + " for key " + repr(key) + "." + self.idebug(data))
                        raise DAError("You need to have a choices element if you want to set a variable to an object." + self.idebug(data))
                            raise DAError("choices exclude list is not in appropriate format" + self.idebug(data))
                            raise DAError("default list is not in appropriate format" + self.idebug(data))
                        raise DAError("Invalid variable name " + repr(field_info['saveas']) + "." + self.idebug(data))
                                    raise DAError("Missing or invalid variable name " + repr(field_info['saveas']) + "." + self.idebug(data))
                elif 'note' in field or 'html' or 'raw html' in field:
                    raise DAError("A field was listed without indicating a label or a variable name, and the field was not a note or raw HTML." + self.idebug(data) + " and field_info was " + repr(field_info))
                raise DAError("A review block without a continue button field cannot be mandatory." + self.idebug(data))
                raise DAError("The review must be written in the form of a list." + self.idebug(data))
                    raise DAError("Each individual field in a list of fields must be expressed as a dictionary item, e.g., ' - Fruit: user.favorite_fruit'." + self.idebug(data))
                            raise DAError("In a review block, you cannot mix help text with a button item." + self.idebug(data))  # , css, or script
                            #    raise DAError("Invalid variable name in fields." + self.idebug(data))
                            #    raise DAError("Missing or invalid variable name " + repr(the_saveas) + " ." + self.idebug(data))
                            raise DAError("If you use 'field' or 'fields' to indicate variables in a 'review' section, you must also include a 'label.'" + self.idebug(data))
                                        raise DAError("The set statement must refer to a list." + self.idebug(data))
                                            raise DAError("A set command must refer to a list of dicts." + self.idebug(data))
                                                raise DAError("A set command must refer to a list of dicts with keys as variable names." + self.idebug(data))
                                                raise DAError("Missing or invalid variable name " + repr(the_var) + " ." + self.idebug(data))
                                        raise DAError("The follow up statement must refer to a list." + self.idebug(data))
                                            raise DAError("Invalid variable name in follow up " + repr(var) + "." + self.idebug(data))
                                            raise DAError("Missing or invalid variable name " + repr(var_saveas) + " ." + self.idebug(data))
                                        raise DAError("The " + command + " statement must refer to a list." + self.idebug(data))
                                            raise DAError("Invalid variable name " + repr(undef_var) + " in " + command + "." + self.idebug(data))
                                            raise DAError("Missing or invalid variable name " + repr(undef_saveas) + " ." + self.idebug(data))
                                    raise DAError("An arguments directive must refer to a dictionary.  " + repr(data))
                                raise DAError("Invalid variable name " + repr(the_saveas) + " in fields." + self.idebug(data))
                                raise DAError("Missing or invalid variable name " + repr(the_saveas) + " ." + self.idebug(data))
                            raise DAError("If you use 'label' to label a field in a 'review' section, you must also include a 'field' or 'fields.'" + self.idebug(data))
                                        raise DAError("The set statement must refer to a list." + self.idebug(data))
                                            raise DAError("A set command must refer to a list of dicts." + self.idebug(data))
                                                raise DAError("A set command must refer to a list of dicts with keys as variable names." + self.idebug(data))
                                                raise DAError("Missing or invalid variable name " + repr(the_var) + " ." + self.idebug(data))
                                        raise DAError("The follow up statement must refer to a list." + self.idebug(data))
                                            raise DAError("Invalid variable name in follow up " + command + "." + self.idebug(data))
                                            raise DAError("Missing or invalid variable name " + repr(var_saveas) + " ." + self.idebug(data))
                                        raise DAError("The " + command + " statement must refer to a list." + self.idebug(data))
                                            raise DAError("Invalid variable name " + repr(undef_var) + " in fields " + command + "." + self.idebug(data))
                                            raise DAError("Missing or invalid variable name " + repr(undef_saveas) + " ." + self.idebug(data))
                                    raise DAError("An arguments directive must refer to a dictionary.  " + repr(data))
                                raise DAError("Invalid variable name " + repr(the_saveas) + " in fields." + self.idebug(data))
                                raise DAError("Missing or invalid variable name " + repr(the_saveas) + " ." + self.idebug(data))
                    raise DAError("A field in a review list was listed without indicating a label or a variable name, and the field was not a note or raw HTML." + self.idebug(field_info))
                raise DAError("No question type could be determined for this section." + self.idebug(data))
                #     raise DAError("Question ID " + str(self.id) + " results in duplicate question name")
                    raise DAError('Unknown data type in attachment skip undefined.' + self.idebug(target))
                    raise DAError("A checkbox export value must be a string." + self.idebug(target))
                    raise DAError("A decimal places directive must be an integer or string." + self.idebug(target))
                        raise DAError('An initial yaml file must be a string.' + self.idebug(target))
                        raise DAError('An additional yaml file must be a string.' + self.idebug(target))
                    raise DAError('The template file must be a string.' + self.idebug(target))
                    raise DAError('The rtf template file must be a string.' + self.idebug(target))
                    raise DAError('The docx reference file must be a string.' + self.idebug(target))
                    raise DAError('The usedefs included in an attachment must be specified as a list of strings or a single string.' + self.idebug(target))
                        raise DAError('The defs in an attachment must be strings.' + self.idebug(target))
                        raise DAError('Referred to a non-existent def "' + def_key + '."  All defs must be defined before they are used.' + self.idebug(target))
                    raise DAError('A variable name cannot be None.' + self.idebug(target))
                    raise DAError('Unknown data type ' + str(type(target['metadata'])) + ' in attachment metadata.' + self.idebug(target))
                                raise DAError('Unknown data type ' + str(type(sub_data)) + ' in list in attachment metadata' + self.idebug(target))
                        raise DAError('Unknown data type ' + str(type(data)) + ' in key in attachment metadata' + self.idebug(target))
                        raise DAError('A content file must be specified as text, a list of text filenames, or a dictionary where the one key is code' + self.idebug(target))
                            raise DAError('A content file must be specified as text, a list of text filenames, or a dictionary where the one key is code' + self.idebug(target))
                            raise DAError('Unable to read content file ' + str(content_file) + ' after trying to find it at ' + str(file_to_read) + self.idebug(target))
                        raise DAError('Unknown data type in attachment "update references".' + self.idebug(target))
                    raise DAError('Fields supplied to attachment but no pdf template file or docx template file supplied' + self.idebug(target))
                    raise DAError('You cannot use a pdf template file and a docx template file at the same time' + self.idebug(target))
                            raise DAError('Unknown data type in attachment valid formats.' + self.idebug(target))
                            raise DAError('Valid formats cannot include "rtf to docx" when "docx template file" is used' + self.idebug(target))
                        raise DAError(template_type + ' template file supplied to attachment must be a string, dict, or list' + self.idebug(target))
                        raise DAError(template_type + ' template file supplied to attachment must be a string or dict' + self.idebug(target))
                    raise DAError('fields supplied to attachment must be a list or dictionary' + self.idebug(target))
                            raise DAError('docx template file supplied to attachment must be a string or dict' + self.idebug(target))
                                raise DAError("Missing docx template file " + template_file.original_reference())
                            raise DAError('The field variables must be expressed in the form of a list' + self.idebug(target))
                                raise DAError('The variable ' + str(varname) + " cannot be used in a code list" + self.idebug(target))
                            raise DAError('The raw field variables must be expressed in the form of a list' + self.idebug(target))
                                raise DAError('The variable ' + str(varname) + " cannot be used in a code list" + self.idebug(target))
                                raise DAError('The field code must be expressed in the form of a dictionary' + self.idebug(target))
                    raise DAError('Unknown data type in attachment valid formats.' + self.idebug(target))
                    raise DAError('Valid formats cannot include both "rtf to docx" and "docx."' + self.idebug(target))
                    raise DAError('Unknown data type in attachment persistent.' + self.idebug(target))
                    raise DAError('Unknown data type in attachment public.' + self.idebug(target))
                            raise DAError('Unknown data type in attachment allow privileges.' + self.idebug(target))
                            raise DAError('Unknown data type in attachment allow users.' + self.idebug(target))
                    raise DAError('Unknown data type in attachment hyperlink style.' + self.idebug(target))
                    raise DAError('Unknown data type in attachment pdf/a.' + self.idebug(target))
                    raise DAError('Unknown data type in attachment tagged pdf.' + self.idebug(target))
                raise DAError("No content provided in attachment." + self.idebug(target))
                    new_iterators[iterator_index] = str(list_indexno)
                                    raise DAError("Variable name " + from_safeid(field.saveas) + " is invalid: " + parse_result['reason'])
                            raise DAError("Failure while processing field with datatype of object: " + err.__class__.__name__ + " " + str(err))
                        raise DAError("Variable name " + from_safeid(field.saveas) + " is invalid: " + parse_result['reason'])
            raise DAError("Multiple choices need to be provided in list form.  " + self.idebug(the_list))
                raise DAError("Unknown data type for the_dict in parse_fields.  " + self.idebug(the_list))
                    raise DAError("Unknown data type in parse_fields:" + str(type(value)) + ".  " + self.idebug(the_list))
                for key in ('template', 'field_data', 'images', 'data_strings', 'convert_to_pdf_a', 'convert_to_tagged_pdf', 'password', 'owner_password', 'template_password', 'update_references', 'permissions', 'rendering_font'):
                                raise DAError("pdf template file " + attachment['options']['pdf_template_file'].original_reference() + " not found")
                            the_pdf_file = docassemble.base.pdftk.fill_template(the_template_path, data_strings=result['data_strings'], images=result['images'], editable=result['editable'], pdfa=result['convert_to_pdf_a'], password=result['password'], owner_password=result['owner_password'], template_password=result['template_password'], default_export_value=default_export_value, replacement_font=result['rendering_font'])
                            for key in ('images', 'data_strings', 'convert_to_pdf_a', 'convert_to_tagged_pdf', 'password', 'owner_password', 'template_password', 'update_references', 'permissions', 'rendering_font'):
                                    raise DAError("prepare_attachment: error downloading " + str(the_filename) + ": " + str(err))
                        raise DAError("prepare_attachment: error obtaining template file from code: " + repr(the_orig_filename))
                                        raise DAError("Missing docx template file " + docx_reference.original_reference())
            raise DAError("Unknown data type in manual choices selection: " + re.sub(r'[<>]', '', repr(data)))
                        error_to_raise = DAError(f'Error reading YAML file {source.path} in the block on line {line_number}\n\nDocument source code was:\n\n---\n{source_code.strip()}\n---\n\nError was:\n\n{format_yaml_errmess(errMess, source.path, line_number)}')
                        error_to_raise = DAError(f'Error reading YAML file {source.path} in the block on line {line_number}\n\nDocument source code was:\n\n---\n{source_code.strip()}\n---\n\nError was:\n\n' + str(errMess.__class__.__name__))
                        raise DAError(f"Syntax Exception: {qError}\n\nIn file {source.path} in the block on line {line_number} from package {source_package}:\n{source_code}")
                        raise DAError(f"Compile Exception: {qError}\n\nIn file {source.path} in the block on line {line_number} from package {source_package}:\n{source_code}")
                        raise DAError(f"Syntax Error: {qError}\n\nIn file {source.path} in the block on line {line_number} from package {source_package}:\n{source_code}")
                    raise DAError("There appears to be a circularity.  Variables involved: " + ", ".join(variables_sought) + ".")
                                    raise DAError("Invalid name " + interview_status.current_info['arguments'][the_key])
                                    raise DAError("Invalid name " + interview_status.current_info['arguments'][the_key])
                                        raise DAError("An embedded question can only be a code block or a regular question block.  The question type was " + getattr(the_question, 'question_type', 'unknown'))
                                raise DAError("NameError: " + str(the_exception) + extra)
                    raise DAError('Got error ' + str(the_error) + " " + traceback.format_exc() + "\nHistory was " + pprint.pformat(interview_status.seeking))
                        raise DAError(str(qError) + "\n\n" + str(self.idebug(self.data_for_debug)))
                    raise DAError("no question available: " + str(qError))
                        raise DAError(str(qError) + "\n\n" + str(self.idebug(self.data_for_debug)))
                    raise DAError("no question available: " + str(qError))
            raise DAError("There appears to be an infinite loop.  Variables in stack are " + ", ".join(sorted(variable_stack)) + ".")
        #     raise DAError("Infinite loop: " + missingVariable + " already looked for, where stack is " + str(variable_stack))
                raise DAError("Infinite loop detected while looking for " + missing_var)
                                            raise DAError("askfor: error downloading " + str(the_filename) + ": " + str(err))
                                raise DAError("askfor: error obtaining template file from code: " + repr(the_orig_filename))
                    raise DAError("Infinite loop: " + missingVariable + " already looked for, where stack is " + str(variable_stack))
                            raise DAError("NameError: " + str(the_exception) + extra)
                #    raise DAError("Infinite loop: " + missingVariable + " already looked for, where stack is " + str(variable_stack))
                    # raise DAError("Problem setting that variable")
                    raise DAError(str(qError) + "\n\n" + str(self.idebug(self.data_for_debug)))
                raise DAError("no question available in askfor: " + str(qError))
                    raise DAError(str(qError) + "\n\n" + str(self.idebug(self.data_for_debug)))
                raise DAError("no question available in askfor: " + str(qError))
        raise DAError("Unknown data type in choices selection: " + re.sub(r'[<>]', '', repr(data)))
        raise DAError("Variable name " + saveas + " is invalid: " + parse_result['reason'])
        raise DAError("Missing docx template file " + os.path.basename(the_path))
        raise DAError("There was an error parsing the docx file: " + the_err.__class__.__name__ + " " + str(the_err))
def fill_template(template, data_strings=None, data_names=None, hidden=None, readonly=None, images=None, pdf_url=None, editable=True, pdfa=False, password=None, owner_password=None, template_password=None, default_export_value=None, replacement_font=None):
    if pdfa or not editable:
            subprocess_arguments.append('flatten')
        pdf.Root.AcroForm.NeedAppearances = True
        validators.DataRequired(word('Package name is required')), validate_name])
        validators.DataRequired(word('Package name is required')), validate_name])
    giturl = StringField(word('GitHub URL'))
    gitbranch = SelectField(word('GitHub Branch'))
    pippackage = StringField(word('Package on PyPI'))
    playground_name = StringField(word('Name'), [validators.Length(min=1, max=255)])
    file_name = StringField(word('Name'), [validators.Length(min=1, max=255)])
        validators.DataRequired(word('Project name is required')), validate_project_name])
        validators.DataRequired(word('Project name is required')), validate_project_name])
    github_url = StringField(word('GitHub URL'))
    github_branch = SelectField(word('GitHub Branch'))
    pypi = StringField(word('PyPI package'))
    original_file_name = StringField(word('Original Name'))
                                                              validate_package_name])
    license = StringField(word('License'), default='The MIT License (MIT)', validators=[validators.Length(min=0, max=255)])
    author_name = StringField(word('Author Name'), validators=[validators.Length(min=0, max=255)])
    author_email = StringField(word('Author E-mail'), validators=[validators.Length(min=0, max=255)])
    description = StringField(word('Description'), validators=[validators.Length(min=0, max=255)], default="A docassemble extension.")
    version = StringField(word('Version'), validators=[validators.Length(min=0, max=255), validate_package_version], default="0.0.1")
    url = StringField(word('URL'), validators=[validators.Length(min=0, max=255)], default="")
    github_branch_new = StringField(word('Name of new branch'))
    name = StringField(word('Name'), validators=[validators.Length(min=1, max=255)])
from docassemble.base.error import DAError, DAErrorNoEndpoint, DAErrorMissingVariable, DAErrorCompileError, DAValidationError, DAException, DANotFoundError, DAInvalidFilename

    do_redirect = False
            do_redirect = True
        if do_redirect:
                        for item in key_to_orig_key.keys():
            if ($(this).hasClass('combobox')){
            if ($(this).hasClass('combobox')){
    if isinstance(the_error, (DAError, DANotFoundError, DAInvalidFilename)):

    show_debug = not bool((not DEBUG) and isinstance(the_error, (DAError, DAInvalidFilename)))
from flask import flash, current_app, request, abort
from flask_login import current_user
from sqlalchemy import select
    first_name = StringField(word('First name'), [validators.Length(min=0, max=255)])
    last_name = StringField(word('Last name'), [validators.Length(min=0, max=255)])
    country = StringField(word('Country code'), [validators.Length(min=0, max=2)])
    subdivisionfirst = StringField(word('First subdivision'), [validators.Length(min=0, max=64)])
    subdivisionsecond = StringField(word('Second subdivision'), [validators.Length(min=0, max=64)])
    subdivisionthird = StringField(word('Third subdivision'), [validators.Length(min=0, max=64)])
    organization = StringField(word('Organization'), [validators.Length(min=0, max=64)])
    language = StringField(word('Language'), [validators.Length(min=0, max=64)])
    timezone = SelectField(word('Time Zone'), [validators.Length(min=0, max=64)])
    nickname = StringField(word('Nickname'), [fix_nickname])
        da_registration_restrict_validator])
    first_name = StringField(word('First name'), [validators.Length(min=0, max=255)])
    last_name = StringField(word('Last name'), [validators.Length(min=0, max=255)])
    country = StringField(word('Country code'), [validators.Length(min=0, max=2)])
    subdivisionfirst = StringField(word('First subdivision'), [validators.Length(min=0, max=64)])
    subdivisionsecond = StringField(word('Second subdivision'), [validators.Length(min=0, max=64)])
    subdivisionthird = StringField(word('Third subdivision'), [validators.Length(min=0, max=64)])
    organization = StringField(word('Organization'), [validators.Length(min=0, max=64)])
    language = StringField(word('Language'), [validators.Length(min=0, max=64)])
    timezone = SelectField(word('Time Zone'), [validators.Length(min=0, max=64)])
    pypi_username = StringField(word('PyPI Username'), [validators.Length(min=0, max=255)])
    email = StringField(word('E-mail'))
    email = StringField(word('E-mail'), validators=[Optional(), Email(word('Must be a valid e-mail address'))])
    reason = StringField(word('Reason for needing developer account (optional)'))
    first_name = StringField(word('First name'), [validators.Length(min=0, max=255)])
    last_name = StringField(word('Last name'), [validators.Length(min=0, max=255)])
    phone_number = StringField(word('Phone number'), [validators.Length(min=5, max=255)])
    phone_number = StringField(word('Phone number'), [validators.Length(min=5, max=255)])
    verification_code = StringField(word('Verification code'), [validators.Length(min=daconfig['verification code digits'], max=daconfig['verification code digits'])])
    phone_number = StringField(word('Phone number'), [validators.Length(min=5, max=255)])
        validators.Email(word('Invalid e-mail address')),
        ])

Fixed code:
## [1.4.97] - 2024-02-29

### Added
- The `pdftk` option under `attachment` and `features` for filling in
  `pdf template file` attachments using pdftk instead of pikepdf.
### Changed
- During the Docker image build process, `pandoc` will run once, so
  that the first user to assemble a document with `pandoc` will not
  experience slowness due to LaTeX needing to generate files.
- Appearance streams will be generated when using `pdf template file`.
- Error messages related to problems in the source code will no longer
  be displayed to the user unless the user is an administrator or
  developer. If you want these error messages to appear to all users,
  set `debug: True` and `development site is protected: True` in the
  Configuration. The error messages will be available in
  `docassemble.log`.
### Fixed
- Fixed security issue identified by Riyush Ghimire, affecting
  versions 1.4.53 to 1.4.96, that could cause contents of files in the
  filesystem to be revealed. This is a high severity issue and
  upgrading as soon as possible is recommended.
- Fixed security issue identified by Riyush Ghimire, affecting
  versions up to 1.4.96, that allowed an open redirect URL to be formed.
- Fixed security issue identified by Riyush Ghimire, affecting
  versions up to 1.4.96, that would allow HTML or JavaScript
  injection.

&& unzip -o omw-1.4.zip \
&& cd /tmp \
&& mkdir -p /tmp/conv \
&& pandoc --pdf-engine=lualatex -M latextmpdir=./conv -M pdfa=false /usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/data/templates/Legal-Template.yml --template=/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/data/templates/Legal-Template.tex --from=markdown+raw_tex-latex_macros -s -o /tmp/temp.pdf /usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/data/templates/hello.md \
&& rm /tmp/temp.pdf \
&& pandoc --pdf-engine=lualatex -M latextmpdir=./conv -M pdfa=false --template=/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/data/templates/Legal-Template.rtf -s -o /tmp/temp.rtf /usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/data/templates/hello.md \
&& rm /tmp/temp.rtf"
"Field cannot contain HTML": Null
"There was an error. Please contact the system administrator.": Null
class DASourceError(DAError):
    pass

import convertapi
import requests
from pikepdf import Pdf

            need_appearances = False
            try:
                if original.Root.AcroForm.NeedAppearances:
                    need_appearances = True
            except:
                pass
                    if need_appearances is False:
                        try:
                            if additional_pdf.Root.AcroForm.NeedAppearances:
                                need_appearances = True
                        except:
                            pass
            if need_appearances:
                try:
                    original.Root.AcroForm.NeedAppearances = True
                except:
                    logmessage("concatenate_files: an additional file had an AcroForm with NeedAppearances but setting NeedAppearances on the final document resulted in an error")
from docassemble.base.error import DAError, DANotFoundError, MandatoryQuestion, DAErrorNoEndpoint, DAErrorMissingVariable, ForcedNameError, QuestionError, ResponseError, BackgroundResponseError, BackgroundResponseActionError, CommandError, CodeExecute, DAValidationError, ForcedReRun, LazyNameError, DAAttributeError, DAIndexError, DAException, DANameError, DASourceError
            raise DASourceError("A block must be in the form of a dictionary." + self.idebug(orig_data))
            raise DASourceError(orig_data['__error__'])
            raise DASourceError("There can only be one directive in a question.  You had more than one.\nThe directives are yesno, noyes, yesnomaybe, noyesmaybe, fields, buttons, choices, dropdown, combobox, signature, and review" + self.idebug(data))
            raise DASourceError("This block is missing a 'question' directive." + self.idebug(data))
                raise DASourceError("A features section must be a dictionary." + self.idebug(data))
                    raise DASourceError("Table width in features must be an integer." + self.idebug(data))
                    raise DASourceError("progress bar multiplier in features must be between 0 and 1." + self.idebug(data))
            if 'pdftk' in data['features'] and data['features']['pdftk'] in (True, False):
                self.interview.options['use pdftk'] = data['features']['pdftk']
                    raise DASourceError("A features section checkin interval entry must be an integer." + self.idebug(data))
                    raise DASourceError("A features section checkin interval entry must be at least 1000, if not 0." + self.idebug(data))
                        raise DASourceError("A features section " + key + " entry must be a list or plain text." + self.idebug(data))
                        raise DASourceError("A features section " + key + " entry must be plain text." + self.idebug(data))
                        raise DASourceError("The " + key + " in features did not contain a valid date." + self.idebug(data))
                raise DASourceError("An only sets phrase must be text or a list." + self.idebug(data))
            raise DASourceError("A block can be a question block or a code block but cannot be both at the same time." + self.idebug(data))
                raise DASourceError("The 'event' designator is for special screens that do not gather information and can only be used with 'buttons' or with no other controls." + self.idebug(data))
                raise DASourceError("A 'translations' block must be a list" + self.idebug(data))
                    raise DASourceError("A 'translations' block must be a list of text items" + self.idebug(data))
                    raise DASourceError("Invalid translations entry '" + item + "'.  A translations entry must refer to a file ending in .xlsx, .xlf, or .xliff." + self.idebug(data))
                    raise DASourceError("Invalid translations entry: " + item + ".  A translations entry must refer to a data sources file" + self.idebug(data))
                raise DASourceError("An on change block must be a dictionary." + self.idebug(data))
                raise DASourceError("An on change block must not contain any other keys." + self.idebug(data))
                    raise DASourceError("An on change block must be a dictionary where the keys are field names and the values are Python code." + self.idebug(data))
                raise DASourceError("A sections list must be a list." + self.idebug(data))
                raise DASourceError("A progressive directive can only be used with sections." + self.idebug(data))
                raise DASourceError("A progressive directive can only be true or false." + self.idebug(data))
                raise DASourceError("An auto open directive can only be used with sections." + self.idebug(data))
                raise DASourceError("An auto open directive can only be true or false." + self.idebug(data))
                raise DASourceError("Invalid machine learning storage entry '" + str(data['machine learning storage']) + ".'  A machine learning storage entry must refer to a file ending in .json." + self.idebug(data))
                raise DASourceError("Invalid machine learning storage entry: " + str(data['machine learning storage']) + self.idebug(data))
                        raise DASourceError("When allowed to set is a list, it must be a list of text items." + self.idebug(data))
                raise DASourceError("When allowed to set is not a list, it must be plain text." + self.idebug(data))
                    raise DASourceError("A usedefs section must consist of a list of strings or a single string." + self.idebug(data))
                    raise DASourceError('Referred to a non-existent def "' + usedef + '."  All defs must be defined before they are used.' + self.idebug(data))
                raise DASourceError("You can only set the section from a question." + self.idebug(data))
                raise DASourceError("You cannot set a continue button label if the type of question is yesno, noyes, yesnomaybe, noyesmaybe, or buttons." + self.idebug(data))
                raise DASourceError("You cannot set a resume button label if the type of question is not review." + self.idebug(data))
                raise DASourceError("You cannot set the skip undefined directive if the type of question is not review." + self.idebug(data))
                raise DASourceError("You cannot set list collect without a fields specifier." + self.idebug(data))
                raise DASourceError("Invalid data under list collect." + self.idebug(data))
                raise DASourceError("You cannot use the mandatory modifier and the initial modifier at the same time." + self.idebug(data))
                raise DASourceError("You cannot use the mandatory modifier on this type of block." + self.idebug(data))
                    raise DASourceError("An attachment option must a dictionary." + self.idebug(data))
                                raise DASourceError('An initial yaml file must be a string.' + self.idebug(data))
                                raise DASourceError('An additional yaml file must be a string.' + self.idebug(data))
                            raise DASourceError('The template file must be a string.' + self.idebug(data))
                            raise DASourceError('The rtf template file must be a string.' + self.idebug(data))
                            raise DASourceError('The docx reference file must be a string.' + self.idebug(data))
                raise DASourceError("A script section must be plain text." + self.idebug(data))
                raise DASourceError("A css section must be plain text." + self.idebug(data))
            raise DASourceError("Only a code block can be marked as initial." + self.idebug(data))
                    raise DASourceError("An objects section cannot contain a nested list." + self.idebug(data))
                raise DASourceError("A data block variable name must be plain text." + self.idebug(data))
                raise DASourceError("A data from code block variable name must be plain text." + self.idebug(data))
                # raise DASourceError("An objects section must be organized as a list." + self.idebug(data))
                    raise DASourceError("An objects section cannot contain a nested list." + self.idebug(data))
            #     raise DASourceError("The id " + str(data['id']) + " is already in use by another block.  Id names must be unique." + self.idebug(data))
                raise DASourceError("A 'ga id' must refer to text." + self.idebug(data))
                raise DASourceError("A 'segment id' must refer to text." + self.idebug(data))
                raise DASourceError("A 'segment' must refer to a dictionary." + self.idebug(data))
                    raise DASourceError("An 'id' under 'segment' must refer to text." + self.idebug(data))
                    raise DASourceError("An 'arguments' under 'segment' must refer to a dictionary." + self.idebug(data))
                        raise DASourceError("Each item under 'arguments' in a 'segment' must be plain text." + self.idebug(data))
                raise DASourceError("An 'order' block cannot be combined with another type of block." + self.idebug(data))
                raise DASourceError("An 'order' block must be a list." + self.idebug(data))
                raise DASourceError("The '" + key + "' section needs to be a dictionary, not a list or text." + self.idebug(data))
                        raise DASourceError("Each item in the 'image sets' section needs to be a dictionary, not a list.  Each dictionary item should have an 'images' definition (which can be a dictionary or list) and an optional 'attribution' definition (which must be text)." + self.idebug(data))
                    raise DASourceError("Each item in the 'images' section needs to be a dictionary, not a list." + self.idebug(data))
                        raise DASourceError("An attribution in an 'image set' section cannot be a dictionary or a list." + self.idebug(data))
                            raise DASourceError("An 'images' definition in an 'image set' item must be a dictionary or a list." + self.idebug(data))
                        raise DASourceError("An 'images' section must be a dictionary or a list." + self.idebug(data))
                raise DASourceError("A def name must be a string." + self.idebug(data))
                    raise DASourceError("A mako template definition must be a string or a list of strings." + self.idebug(data))
                        raise DASourceError("A mako template definition must be a string." + self.idebug(data))
                raise DASourceError("An interview help section must not be in the form of a list." + self.idebug(data))
                        raise DASourceError("An interview help audio section must be in the form of a text item or a list of text items." + self.idebug(data))
                        raise DASourceError("An interview help video section must be in the form of a text item or a list of text items." + self.idebug(data))
                    raise DASourceError("A heading within an interview help section must be text, not a list or a dictionary." + self.idebug(data))
                    raise DASourceError("Help content must be text, not a list or a dictionary." + self.idebug(data))
                raise DASourceError("No content section was found in an interview help section." + self.idebug(data))
                    raise DASourceError("Help label must be text, not a list or a dictionary." + self.idebug(data))
                raise DASourceError("A default screen parts block must be in the form of a dictionary." + self.idebug(data))
                        raise DASourceError("A default screen parts block must be a dictionary of text keys and text values." + self.idebug(data))
                raise DASourceError("A default validation messages block must be in the form of a dictionary." + self.idebug(data))
                    raise DASourceError("A validation messages block must be a dictionary of text keys and text values." + self.idebug(data))
                    raise DASourceError("A metadata directive cannot be mixed with other directives." + self.idebug(data))
                raise DASourceError("A metadata section must be organized as a dictionary." + self.idebug(data))
                raise DASourceError("A modules section must be organized as a list." + self.idebug(data))
                raise DASourceError("A reset section must be organized as a list." + self.idebug(data))
                raise DASourceError("An imports section must be organized as a list." + self.idebug(data))
                raise DASourceError("Terms must be organized as a dictionary or a list." + self.idebug(data))
                    raise DASourceError("A terms section organized as a list must be a list of dictionary items." + self.idebug(data))
                raise DASourceError("Terms must be organized as a dictionary or a list." + self.idebug(data))
                    raise DASourceError("A terms section organized as a list must be a list of dictionary items." + self.idebug(data))
                        raise DASourceError("A terms section organized as a list must be a list of dictionary items." + self.idebug(data))
                raise DASourceError("A terms section must be organized as a dictionary or a list." + self.idebug(data))
                        raise DASourceError("An auto terms section organized as a list must be a list of dictionary items." + self.idebug(data))
                raise DASourceError("An auto terms section must be organized as a dictionary or a list." + self.idebug(data))
                raise DASourceError("A default role must be a list or a string." + self.idebug(data))
                raise DASourceError("The role of a question must be a string or a list." + self.idebug(data))
                        raise DASourceError('An include section could not find the file ' + str(questionPath) + '.' + self.idebug(data))
                raise DASourceError("An include section must be organized as a list." + self.idebug(data))
                    raise DASourceError("An action buttons specifier must be a list." + self.idebug(data))
                        raise DASourceError("An action buttons item must be a dictionary." + self.idebug(data))
                        raise DASourceError("An action buttons item must contain an action in plain text." + self.idebug(data))
                        raise DASourceError("The new window specifier in an action buttons item must refer to True or plain text." + self.idebug(data))
                        raise DASourceError("The arguments specifier in an action buttons item must refer to a dictionary." + self.idebug(data))
                        raise DASourceError("An action buttons item must contain a label in plain text." + self.idebug(data))
                        raise DASourceError("The color specifier in an action buttons item must refer to plain text." + self.idebug(data))
                        raise DASourceError("The icon specifier in an action buttons item must refer to plain text." + self.idebug(data))
                        raise DASourceError("The placement specifier in an action buttons item must refer to plain text." + self.idebug(data))
                        raise DASourceError("The css classifier specifier in an action buttons item must refer to plain text." + self.idebug(data))
                        raise DASourceError("The forget prior specifier in an action buttons item must refer to true or false." + self.idebug(data))
                            raise DASourceError("The arguments specifier in an action buttons item must refer to plain items." + self.idebug(data))
                raise DASourceError("An if statement must either be text or a list." + self.idebug(data))
                raise DASourceError("A validation code statement must be text." + self.idebug(data))
                        raise DASourceError("The orelse part of a require section must be organized as a dictionary." + self.idebug(data))
                    raise DASourceError("A require section must have an orelse part." + self.idebug(data))
                raise DASourceError("A require section must be organized as a list." + self.idebug(data))
        #         raise DASourceError("A role section must be text or a list." + self.idebug(data))
                raise DASourceError("A css class can only accompany a question." + self.idebug(data))
                raise DASourceError("A table css class can only accompany a question." + self.idebug(data))
                                raise DASourceError("An audio declaration in a help block can only contain a text item or a list of text items." + self.idebug(data))
                                raise DASourceError("A video declaration in a help block can only contain a text item or a list of text items." + self.idebug(data))
                            raise DASourceError("A content declaration in a help block can only contain text." + self.idebug(data))
                    raise DASourceError("An audio declaration can only contain a text item or a list of text items." + self.idebug(data))
                    raise DASourceError("A video declaration can only contain a text item or a list of text items." + self.idebug(data))
            raise DASourceError("The required modifier can only be used on a signature block" + self.idebug(data))
                raise DASourceError("A check in event must be text or a list." + self.idebug(data))
                raise DASourceError("A yesno must refer to text." + self.idebug(data))
                raise DASourceError("A noyes must refer to text." + self.idebug(data))
                raise DASourceError("A yesnomaybe must refer to text." + self.idebug(data))
                raise DASourceError("A noyesmaybe must refer to text." + self.idebug(data))
                raise DASourceError("A sets phrase must be text or a list." + self.idebug(data))
                raise DASourceError("An event phrase must be text or a list." + self.idebug(data))
                    raise DASourceError("Missing or invalid variable name " + repr(data['field']) + "." + self.idebug(data))
                        raise DASourceError("Missing or invalid variable name " + repr(data['continue button field']) + "." + self.idebug(data))
                    raise DASourceError("A validation messages indicator must be a dictionary." + self.idebug(data))
                        raise DASourceError("A validation messages indicator must be a dictionary of text keys and text values." + self.idebug(data))
                raise DASourceError("A continue button field must be plain text." + self.idebug(data))
                raise DASourceError("A need phrase must be text or a list." + self.idebug(data))
                        raise DASourceError("If 'need' contains a dictionary it can only include keys 'pre' or 'post'." + self.idebug(data))
                            raise DASourceError("A need post phrase must be text or a list." + self.idebug(data))
                            raise DASourceError("A need pre phrase must be text or a list." + self.idebug(data))
                    raise DASourceError("In 'need', the items must be text strings." + self.idebug(data))
                raise DASourceError("The target of a template must be plain text." + self.idebug(data))
                raise DASourceError("A target directive can only be used with a template." + self.idebug(data))
                raise DASourceError("A table definition must have definitions for table, row, and column." + self.idebug(data))
                raise DASourceError("The row part of a table definition must be plain Python code." + self.idebug(data))
                raise DASourceError("The column part of a table definition must be a list." + self.idebug(data))
                    raise DASourceError("The column items in a table definition must be dictionaries." + self.idebug(data))
                    raise DASourceError("A column item in a table definition cannot be empty." + self.idebug(data))
                        raise DASourceError("The edit directive must be a list of attributes, or True or False" + self.idebug(data))
                            raise DASourceError("The edit directive must be a list of attribute names" + self.idebug(data))
                    raise DASourceError("The edit directive must be a list of attributes, or True or False" + self.idebug(data))
                        raise DASourceError("The read only directive must be plain text referring to an attribute" + self.idebug(data))
                        raise DASourceError("The edit header directive must be text" + self.idebug(data))
                        raise DASourceError("The read only directive must be plain text referring to an attribute" + self.idebug(data))
                        raise DASourceError("The edit header directive must be text" + self.idebug(data))
                    raise DASourceError('A content file must be specified as text, as a list of text filenames, or as a dictionary with code as the key' + self.idebug(data))
                        raise DASourceError('A content file must be specified as text, as a list of text filenames, or as a dictionary with code as the key' + self.idebug(data))
                    #    raise DASourceError('The content file ' + str(data['content file']) + ' is not a markdown file ' + str(file_to_read) + self.idebug(data))
                        raise DASourceError('Unable to read content file ' + str(data['content file']) + ' after trying to find it at ' + str(file_to_read) + self.idebug(data))
                raise DASourceError("A template must designate a single variable expressed as text." + self.idebug(data))
                raise DASourceError("The content of a template must be expressed as text." + self.idebug(data))
                raise DASourceError("A code section must be text, not a list or a dictionary." + self.idebug(data))
            #    raise DASourceError("A reconsider directive must be true or false." + self.idebug(data))
                    raise DASourceError("A reconsider directive must be true, false, a single variable or a list." + self.idebug(data))
                        raise DASourceError("A reconsider directive must refer to variable names expressed as text." + self.idebug(data))
                raise DASourceError("A undefine directive must a single variable or a list." + self.idebug(data))
                    raise DASourceError("A undefine directive must refer to variable names expressed as text." + self.idebug(data))
                raise DASourceError("A continue button field must be plain text." + self.idebug(data))
                raise DASourceError("The fields must be written in the form of a list." + self.idebug(data))
                    raise DASourceError("Each individual field in a list of fields must be expressed as a dictionary item, e.g., ' - Fruit: user.favorite_fruit'." + self.idebug(data))
                        raise DASourceError("Invalid datatype of hidden field." + self.idebug(data))
                        raise DASourceError("A multiple choice field must refer to a list of choices." + self.idebug(data))
                            raise DASourceError("An ajax field must have an associated action." + self.idebug(data))
                            raise DASourceError("An ajax field cannot contain a list of choices except through an action." + self.idebug(data))
                        raise DASourceError("A multiple choice field must refer to a list of choices." + self.idebug(data))
                    raise DASourceError("An object labeler can only be used with an object data type." + self.idebug(data))
                    raise DASourceError("You cannot combine note, html, and/or raw html in a single field." + self.idebug(data))
                            raise DASourceError("A validation messages indicator must be a dictionary." + self.idebug(data))
                                raise DASourceError("A validation messages indicator must be a dictionary of text keys and text values." + self.idebug(data))
                                    raise DASourceError("An allow privileges specifier must be a list of plain text items or code." + self.idebug(data))
                            raise DASourceError("An allow privileges specifier must be a list of plain text items or code." + self.idebug(data))
                                    raise DASourceError("An allow users specifier must be a list of integers and plain text items or code." + self.idebug(data))
                            raise DASourceError("An allow users specifier must be a list of integers and plain text items or code." + self.idebug(data))
                            raise DASourceError("A js show if or js hide if expression must be a string" + self.idebug(data))
                            raise DASourceError("A js disable if or js enable if expression must be a string" + self.idebug(data))
                                        raise DASourceError(key + " cannot be combined with " + other_key + "." + self.idebug(data))
                                    raise DASourceError("You cannot mix js show if and non-js show if" + self.idebug(data))
                                    raise DASourceError("You cannot mix js disable if and non-js show if" + self.idebug(data))
                                raise DASourceError("The keys of '" + key + "' must be 'variable' and 'is,' or 'code.'" + self.idebug(data))
                            raise DASourceError("The keys of '" + key + "' cannot be a list" + self.idebug(data))
                            raise DASourceError("Invalid variable name in show if/hide if." + self.idebug(data))
                                        raise DASourceError(key + " cannot be combined with " + other_key + "." + self.idebug(data))
                                    raise DASourceError("You cannot mix js show if and non-js disable if." + self.idebug(data))
                                    raise DASourceError("You cannot mix js disable if and non-js disable if." + self.idebug(data))
                                raise DASourceError("The keys of '" + key + "' must be 'variable' and 'is,' or 'code.'" + self.idebug(data))
                            raise DASourceError("The keys of '" + key + "' cannot be a list" + self.idebug(data))
                            raise DASourceError("Invalid variable name in " + key + '.' + self.idebug(data))
                            raise DASourceError("A 'disable others' directive cannot be used with this data type." + self.idebug(data))
                            raise DASourceError("A 'disable others' directive must be True, False, or a list of variable names." + self.idebug(data))
                            raise DASourceError("An 'uncheck others' directive must be True, False, or a list of variable names." + self.idebug(data))
                            raise DASourceError("A 'check others' directive must be True, False, or a list of variable names." + self.idebug(data))
                            raise DASourceError("If the datatype of a field is 'range', you must provide a min and a max." + self.idebug(data))
                                raise DASourceError("An exclude entry cannot be a dictionary." + self.idebug(data))
                            raise DASourceError("address autocomplete must be a Python expression, a dictionary, or a boolean value." + self.idebug(data))
                            raise DASourceError(key + " is not in the correct format." + self.idebug(data))
                                raise DASourceError(key + " has an invalid key " + repr(item) + "." + self.idebug(data))
                            raise DASourceError(key + ' must specify a width.' + self.idebug(data))
                                    raise DASourceError(key + " " + subkey + " must be a number between 1 and 12, or a Python expression." + self.idebug(data))
                                    raise DASourceError(key + " " + subkey + " must be True or False, or a Python expression." + self.idebug(data))
                            raise DASourceError(key + " is not in the correct format." + self.idebug(data))
                                raise DASourceError(key + " has an invalid key " + repr(item) + "." + self.idebug(data))
                            raise DASourceError(key + ' must specify a width.' + self.idebug(data))
                            raise DASourceError(key + " width must be a number between 1 and 12, or a Python expression." + self.idebug(data))
                            raise DASourceError("An action must be plain text" + self.idebug(data))
                            raise DASourceError("A trigger at must an integer greater than one" + self.idebug(data))
                                raise DASourceError("choices is not in appropriate format" + self.idebug(data))
                                raise DASourceError("An exclude entry cannot be a dictionary." + self.idebug(data))
                            raise DASourceError("If you use 'field' to indicate a variable in a 'fields' section, you must also include a 'label.'" + self.idebug(data))
                            raise DASourceError("Fields in a 'field' section must be plain text." + self.idebug(data))
                            raise DASourceError("Missing or invalid variable name " + repr(field[key]) + "." + self.idebug(data))
                            raise DASourceError("If you use 'label' to label a field in a 'fields' section, you must also include a 'field.'" + self.idebug(data))
                            raise DASourceError("Syntax error: field label '" + str(key) + "' overwrites previous label, '" + str(field_info['label'].original_text) + "'" + self.idebug(data))
                            raise DASourceError("Fields in a 'field' section must be plain text." + self.idebug(data))
                            raise DASourceError("Missing or invalid variable name " + repr(field[key]) + " for key " + repr(key) + "." + self.idebug(data))
                        raise DASourceError("You need to have a choices element if you want to set a variable to an object." + self.idebug(data))
                            raise DASourceError("choices exclude list is not in appropriate format" + self.idebug(data))
                            raise DASourceError("default list is not in appropriate format" + self.idebug(data))
                        raise DASourceError("Invalid variable name " + repr(field_info['saveas']) + "." + self.idebug(data))
                                    raise DASourceError("Missing or invalid variable name " + repr(field_info['saveas']) + "." + self.idebug(data))
                elif 'note' in field or 'html' in field or 'raw html' in field:
                    raise DASourceError("A field was listed without indicating a label or a variable name, and the field was not a note or raw HTML." + self.idebug(data) + " and field_info was " + repr(field_info))
                raise DASourceError("A review block without a continue button field cannot be mandatory." + self.idebug(data))
                raise DASourceError("The review must be written in the form of a list." + self.idebug(data))
                    raise DASourceError("Each individual field in a list of fields must be expressed as a dictionary item, e.g., ' - Fruit: user.favorite_fruit'." + self.idebug(data))
                            raise DASourceError("In a review block, you cannot mix help text with a button item." + self.idebug(data))  # , css, or script
                            #    raise DASourceError("Invalid variable name in fields." + self.idebug(data))
                            #    raise DASourceError("Missing or invalid variable name " + repr(the_saveas) + " ." + self.idebug(data))
                            raise DASourceError("If you use 'field' or 'fields' to indicate variables in a 'review' section, you must also include a 'label.'" + self.idebug(data))
                                        raise DASourceError("The set statement must refer to a list." + self.idebug(data))
                                            raise DASourceError("A set command must refer to a list of dicts." + self.idebug(data))
                                                raise DASourceError("A set command must refer to a list of dicts with keys as variable names." + self.idebug(data))
                                                raise DASourceError("Missing or invalid variable name " + repr(the_var) + " ." + self.idebug(data))
                                        raise DASourceError("The follow up statement must refer to a list." + self.idebug(data))
                                            raise DASourceError("Invalid variable name in follow up " + repr(var) + "." + self.idebug(data))
                                            raise DASourceError("Missing or invalid variable name " + repr(var_saveas) + " ." + self.idebug(data))
                                        raise DASourceError("The " + command + " statement must refer to a list." + self.idebug(data))
                                            raise DASourceError("Invalid variable name " + repr(undef_var) + " in " + command + "." + self.idebug(data))
                                            raise DASourceError("Missing or invalid variable name " + repr(undef_saveas) + " ." + self.idebug(data))
                                    raise DASourceError("An arguments directive must refer to a dictionary.  " + repr(data))
                                raise DASourceError("Invalid variable name " + repr(the_saveas) + " in fields." + self.idebug(data))
                                raise DASourceError("Missing or invalid variable name " + repr(the_saveas) + " ." + self.idebug(data))
                            raise DASourceError("If you use 'label' to label a field in a 'review' section, you must also include a 'field' or 'fields.'" + self.idebug(data))
                                        raise DASourceError("The set statement must refer to a list." + self.idebug(data))
                                            raise DASourceError("A set command must refer to a list of dicts." + self.idebug(data))
                                                raise DASourceError("A set command must refer to a list of dicts with keys as variable names." + self.idebug(data))
                                                raise DASourceError("Missing or invalid variable name " + repr(the_var) + " ." + self.idebug(data))
                                        raise DASourceError("The follow up statement must refer to a list." + self.idebug(data))
                                            raise DASourceError("Invalid variable name in follow up " + command + "." + self.idebug(data))
                                            raise DASourceError("Missing or invalid variable name " + repr(var_saveas) + " ." + self.idebug(data))
                                        raise DASourceError("The " + command + " statement must refer to a list." + self.idebug(data))
                                            raise DASourceError("Invalid variable name " + repr(undef_var) + " in fields " + command + "." + self.idebug(data))
                                            raise DASourceError("Missing or invalid variable name " + repr(undef_saveas) + " ." + self.idebug(data))
                                    raise DASourceError("An arguments directive must refer to a dictionary.  " + repr(data))
                                raise DASourceError("Invalid variable name " + repr(the_saveas) + " in fields." + self.idebug(data))
                                raise DASourceError("Missing or invalid variable name " + repr(the_saveas) + " ." + self.idebug(data))
                    raise DASourceError("A field in a review list was listed without indicating a label or a variable name, and the field was not a note or raw HTML." + self.idebug(field_info))
                raise DASourceError("No question type could be determined for this section." + self.idebug(data))
                #     raise DASourceError("Question ID " + str(self.id) + " results in duplicate question name")
                    raise DASourceError('Unknown data type in attachment skip undefined.' + self.idebug(target))
                    raise DASourceError("A checkbox export value must be a string." + self.idebug(target))
                    raise DASourceError("A decimal places directive must be an integer or string." + self.idebug(target))
                        raise DASourceError('An initial yaml file must be a string.' + self.idebug(target))
                        raise DASourceError('An additional yaml file must be a string.' + self.idebug(target))
                    raise DASourceError('The template file must be a string.' + self.idebug(target))
                    raise DASourceError('The rtf template file must be a string.' + self.idebug(target))
                    raise DASourceError('The docx reference file must be a string.' + self.idebug(target))
                    raise DASourceError('The usedefs included in an attachment must be specified as a list of strings or a single string.' + self.idebug(target))
                        raise DASourceError('The defs in an attachment must be strings.' + self.idebug(target))
                        raise DASourceError('Referred to a non-existent def "' + def_key + '."  All defs must be defined before they are used.' + self.idebug(target))
                    raise DASourceError('A variable name cannot be None.' + self.idebug(target))
                    raise DASourceError('Unknown data type ' + str(type(target['metadata'])) + ' in attachment metadata.' + self.idebug(target))
                                raise DASourceError('Unknown data type ' + str(type(sub_data)) + ' in list in attachment metadata' + self.idebug(target))
                        raise DASourceError('Unknown data type ' + str(type(data)) + ' in key in attachment metadata' + self.idebug(target))
                        raise DASourceError('A content file must be specified as text, a list of text filenames, or a dictionary where the one key is code' + self.idebug(target))
                            raise DASourceError('A content file must be specified as text, a list of text filenames, or a dictionary where the one key is code' + self.idebug(target))
                            raise DASourceError('Unable to read content file ' + str(content_file) + ' after trying to find it at ' + str(file_to_read) + self.idebug(target))
                        raise DASourceError('Unknown data type in attachment "update references".' + self.idebug(target))
                    raise DASourceError('Fields supplied to attachment but no pdf template file or docx template file supplied' + self.idebug(target))
                    raise DASourceError('You cannot use a pdf template file and a docx template file at the same time' + self.idebug(target))
                            raise DASourceError('Unknown data type in attachment valid formats.' + self.idebug(target))
                            raise DASourceError('Valid formats cannot include "rtf to docx" when "docx template file" is used' + self.idebug(target))
                        raise DASourceError(template_type + ' template file supplied to attachment must be a string, dict, or list' + self.idebug(target))
                        raise DASourceError(template_type + ' template file supplied to attachment must be a string or dict' + self.idebug(target))
                    raise DASourceError('fields supplied to attachment must be a list or dictionary' + self.idebug(target))
                            raise DASourceError('docx template file supplied to attachment must be a string or dict' + self.idebug(target))
                                raise DASourceError("Missing docx template file " + template_file.original_reference())
                            raise DASourceError('The field variables must be expressed in the form of a list' + self.idebug(target))
                                raise DASourceError('The variable ' + str(varname) + " cannot be used in a code list" + self.idebug(target))
                            raise DASourceError('The raw field variables must be expressed in the form of a list' + self.idebug(target))
                                raise DASourceError('The variable ' + str(varname) + " cannot be used in a code list" + self.idebug(target))
                                raise DASourceError('The field code must be expressed in the form of a dictionary' + self.idebug(target))
                    raise DASourceError('Unknown data type in attachment valid formats.' + self.idebug(target))
                    raise DASourceError('Valid formats cannot include both "rtf to docx" and "docx."' + self.idebug(target))
                    raise DASourceError('Unknown data type in attachment persistent.' + self.idebug(target))
                    raise DASourceError('Unknown data type in attachment public.' + self.idebug(target))
                            raise DASourceError('Unknown data type in attachment allow privileges.' + self.idebug(target))
                            raise DASourceError('Unknown data type in attachment allow users.' + self.idebug(target))
                    raise DASourceError('Unknown data type in attachment hyperlink style.' + self.idebug(target))
                    raise DASourceError('Unknown data type in attachment pdf/a.' + self.idebug(target))
            if 'pdftk' in target:
                if isinstance(target['pdftk'], bool):
                    options['pdftk'] = target['pdftk']
                elif isinstance(target['pdftk'], str):
                    options['pdftk'] = compile(target['pdftk'], '<pdftk expression>', 'eval')
                    self.find_fields_in(target['pdftk'])
                else:
                    raise DASourceError('Unknown data type in attachment pdftk.' + self.idebug(target))
                    raise DASourceError('Unknown data type in attachment tagged pdf.' + self.idebug(target))
                raise DASourceError("No content provided in attachment." + self.idebug(target))
                    try:
                        new_iterators[iterator_index] = str(list_indexno)
                    except IndexError:
                        raise DAException("list collect question needs iterator " + extras['list_iterator'] + " but it was asked in a context where there is no " + extras['list_iterator'])
                                    raise DASourceError("Variable name " + from_safeid(field.saveas) + " is invalid: " + parse_result['reason'])
                            raise DASourceError("Failure while processing field with datatype of object: " + err.__class__.__name__ + " " + str(err))
                        raise DASourceError("Variable name " + from_safeid(field.saveas) + " is invalid: " + parse_result['reason'])
            raise DASourceError("Multiple choices need to be provided in list form.  " + self.idebug(the_list))
                raise DASourceError("Unknown data type for the_dict in parse_fields.  " + self.idebug(the_list))
                    raise DASourceError("Unknown data type in parse_fields:" + str(type(value)) + ".  " + self.idebug(the_list))
                for key in ('template', 'field_data', 'images', 'data_strings', 'convert_to_pdf_a', 'use_pdftk', 'convert_to_tagged_pdf', 'password', 'owner_password', 'template_password', 'update_references', 'permissions', 'rendering_font'):
                                raise DASourceError("pdf template file " + attachment['options']['pdf_template_file'].original_reference() + " not found")
                            the_pdf_file = docassemble.base.pdftk.fill_template(the_template_path, data_strings=result['data_strings'], images=result['images'], editable=result['editable'], pdfa=result['convert_to_pdf_a'], use_pdftk=result['use_pdftk'], password=result['password'], owner_password=result['owner_password'], template_password=result['template_password'], default_export_value=default_export_value, replacement_font=result['rendering_font'])
                            for key in ('images', 'data_strings', 'convert_to_pdf_a', 'use_pdftk', 'convert_to_tagged_pdf', 'password', 'owner_password', 'template_password', 'update_references', 'permissions', 'rendering_font'):
                                    raise DASourceError("prepare_attachment: error downloading " + str(the_filename) + ": " + str(err))
                        raise DASourceError("prepare_attachment: error obtaining template file from code: " + repr(the_orig_filename))
            if 'pdftk' in attachment['options']:
                if isinstance(attachment['options']['pdftk'], bool):
                    result['use_pdftk'] = attachment['options']['pdftk']
                else:
                    result['use_pdftk'] = eval(attachment['options']['pdftk'], the_user_dict)
            else:
                result['use_pdftk'] = self.interview.options.get('use pdftk', False)
                                        raise DASourceError("Missing docx template file " + docx_reference.original_reference())
            raise DASourceError("Unknown data type in manual choices selection: " + re.sub(r'[<>]', '', repr(data)))
                        error_to_raise = DASourceError(f'Error reading YAML file {source.path} in the block on line {line_number}\n\nDocument source code was:\n\n---\n{source_code.strip()}\n---\n\nError was:\n\n{format_yaml_errmess(errMess, source.path, line_number)}')
                        error_to_raise = DASourceError(f'Error reading YAML file {source.path} in the block on line {line_number}\n\nDocument source code was:\n\n---\n{source_code.strip()}\n---\n\nError was:\n\n' + str(errMess.__class__.__name__))
                        raise DASourceError(f"Syntax Exception: {qError}\n\nIn file {source.path} in the block on line {line_number} from package {source_package}:\n{source_code}")
                        raise DASourceError(f"Compile Exception: {qError}\n\nIn file {source.path} in the block on line {line_number} from package {source_package}:\n{source_code}")
                        raise DASourceError(f"Syntax Error: {qError}\n\nIn file {source.path} in the block on line {line_number} from package {source_package}:\n{source_code}")
                    raise DASourceError("There appears to be a circularity.  Variables involved: " + ", ".join(variables_sought) + ".")
                                    raise DASourceError("Invalid name " + interview_status.current_info['arguments'][the_key])
                                    raise DASourceError("Invalid name " + interview_status.current_info['arguments'][the_key])
                                        raise DASourceError("An embedded question can only be a code block or a regular question block.  The question type was " + getattr(the_question, 'question_type', 'unknown'))
                                raise DASourceError("NameError: " + str(the_exception) + extra)
                    raise DASourceError('Got error ' + str(the_error) + " " + traceback.format_exc() + "\nHistory was " + pprint.pformat(interview_status.seeking))
                        raise DASourceError(str(qError) + "\n\n" + str(self.idebug(self.data_for_debug)))
                    raise DASourceError("no question available: " + str(qError))
                        raise DASourceError(str(qError) + "\n\n" + str(self.idebug(self.data_for_debug)))
                    raise DASourceError("no question available: " + str(qError))
            raise DASourceError("There appears to be an infinite loop.  Variables in stack are " + ", ".join(sorted(variable_stack)) + ".")
        #     raise DASourceError("Infinite loop: " + missingVariable + " already looked for, where stack is " + str(variable_stack))
                raise DASourceError("Infinite loop detected while looking for " + missing_var)
                                            raise DASourceError("askfor: error downloading " + str(the_filename) + ": " + str(err))
                                raise DASourceError("askfor: error obtaining template file from code: " + repr(the_orig_filename))
                    raise DASourceError("Infinite loop: " + missingVariable + " already looked for, where stack is " + str(variable_stack))
                            raise DASourceError("NameError: " + str(the_exception) + extra)
                #    raise DASourceError("Infinite loop: " + missingVariable + " already looked for, where stack is " + str(variable_stack))
                    # raise DASourceError("Problem setting that variable")
                    raise DASourceError(str(qError) + "\n\n" + str(self.idebug(self.data_for_debug)))
                raise DASourceError("no question available in askfor: " + str(qError))
                    raise DASourceError(str(qError) + "\n\n" + str(self.idebug(self.data_for_debug)))
                raise DASourceError("no question available in askfor: " + str(qError))
        raise DASourceError("Unknown data type in choices selection: " + re.sub(r'[<>]', '', repr(data)))
        raise DASourceError("Variable name " + saveas + " is invalid: " + parse_result['reason'])
        raise DASourceError("Missing docx template file " + os.path.basename(the_path))
        raise DASourceError("There was an error parsing the docx file: " + the_err.__class__.__name__ + " " + str(the_err))
def fill_template(template, data_strings=None, data_names=None, hidden=None, readonly=None, images=None, pdf_url=None, editable=True, pdfa=False, password=None, owner_password=None, template_password=None, default_export_value=None, replacement_font=None, use_pdftk=False):
    if pdfa or not editable or use_pdftk:
            if pdfa or not editable:
                subprocess_arguments.append('flatten')
            else:
                subprocess_arguments.append('need_appearances')
        pdf.Root.AcroForm.NeedAppearances = True
        pdf.generate_appearance_streams()
        pdf.Root.AcroForm.NeedAppearances = True
from docassemble.webapp.validators import html_validator
        validators.DataRequired(word('Package name is required')), validate_name, html_validator])
        validators.DataRequired(word('Package name is required')), validate_name, html_validator])
    giturl = StringField(word('GitHub URL'), validators=[html_validator])
    gitbranch = SelectField(word('GitHub Branch'), validators=[html_validator])
    pippackage = StringField(word('Package on PyPI'), validators=[html_validator])
    playground_name = StringField(word('Name'), [validators.Length(min=1, max=255), html_validator])
    file_name = StringField(word('Name'), [validators.Length(min=1, max=255), html_validator])
        validators.DataRequired(word('Project name is required')), validate_project_name, html_validator])
        validators.DataRequired(word('Project name is required')), validate_project_name, html_validator])
    github_url = StringField(word('GitHub URL'), validators=[html_validator])
    github_branch = SelectField(word('GitHub Branch'), validators=[html_validator])
    pypi = StringField(word('PyPI package'), validators=[html_validator])
    original_file_name = StringField(word('Original Name'), validators=[html_validator])
                                                              validate_package_name, html_validator])
    license = StringField(word('License'), default='The MIT License (MIT)', validators=[validators.Length(min=0, max=255), html_validator])
    author_name = StringField(word('Author Name'), validators=[validators.Length(min=0, max=255), html_validator])
    author_email = StringField(word('Author E-mail'), validators=[validators.Length(min=0, max=255), html_validator])
    description = StringField(word('Description'), validators=[validators.Length(min=0, max=255), html_validator], default="A docassemble extension.")
    version = StringField(word('Version'), validators=[validators.Length(min=0, max=255), validate_package_version, html_validator], default="0.0.1")
    url = StringField(word('URL'), validators=[validators.Length(min=0, max=255), html_validator], default="")
    github_branch_new = StringField(word('Name of new branch'), validators=[html_validator])
    name = StringField(word('Name'), validators=[validators.Length(min=1, max=255), html_validator])
from docassemble.base.error import DAError, DAErrorNoEndpoint, DAErrorMissingVariable, DAErrorCompileError, DAValidationError, DAException, DANotFoundError, DAInvalidFilename, DASourceError
    if url in ('help', 'login', 'signin', 'restart', 'new_session', 'exit', 'interview', 'logout', 'exit_logout', 'leave', 'register', 'profile', 'change_password', 'interviews', 'dispatch', 'manage', 'config', 'playground', 'playgroundtemplate', 'playgroundstatic', 'playgroundsources', 'playgroundmodules', 'playgroundpackages', 'configuration', 'root', 'temp_url', 'login_url', 'exit_endpoint', 'interview_start', 'interview_list', 'playgroundfiles', 'create_playground_package', 'run', 'run_interview_in_package', 'run_dispatch', 'run_new', 'run_new_dispatch'):
        return url
    if len(safe_url) > 0 and safe_url[0] not in ('?', '#', '/'):
        safe_url = '/' + safe_url
    safe_url = re.sub(r'^//+', '/', safe_url)

    do_a_redirect = False
            do_a_redirect = True
        if do_a_redirect:
                        for item in key_to_orig_key:
            if ($(this).prop('tagName') == 'INPUT' && $(this).hasClass('combobox')){
            if ($(this).prop('tagName') == 'INPUT' && $(this).hasClass('combobox')){
    if isinstance(the_error, DASourceError):
        if (DEBUG and daconfig.get('development site is protected', False)) or (current_user.is_authenticated and current_user.has_role('admin', 'developer')):
            errmess = str(the_error)
        else:
            errmess = word("There was an error. Please contact the system administrator.")
        the_trace = None
        logmessage(str(the_error))
    elif isinstance(the_error, (DAError, DANotFoundError, DAInvalidFilename)):
        try:
            logmessage(errmess)
        except:
            logmessage("Could not log the error message")
    show_debug = not bool((not (DEBUG and daconfig.get('development site is protected', False))) and isinstance(the_error, (DAError, DAInvalidFilename)))

from flask import flash, current_app, request, abort
from flask_login import current_user
from sqlalchemy import select
from docassemble.webapp.validators import html_validator
    first_name = StringField(word('First name'), [validators.Length(min=0, max=255), html_validator])
    last_name = StringField(word('Last name'), [validators.Length(min=0, max=255), html_validator])
    country = StringField(word('Country code'), [validators.Length(min=0, max=2), html_validator])
    subdivisionfirst = StringField(word('First subdivision'), [validators.Length(min=0, max=64), html_validator])
    subdivisionsecond = StringField(word('Second subdivision'), [validators.Length(min=0, max=64), html_validator])
    subdivisionthird = StringField(word('Third subdivision'), [validators.Length(min=0, max=64), html_validator])
    organization = StringField(word('Organization'), [validators.Length(min=0, max=64), html_validator])
    language = StringField(word('Language'), [validators.Length(min=0, max=64), html_validator])
    timezone = SelectField(word('Time Zone'), [validators.Length(min=0, max=64), html_validator])
    nickname = StringField(word('Nickname'), [fix_nickname, html_validator])
        da_registration_restrict_validator,
        html_validator])
    first_name = StringField(word('First name'), [validators.Length(min=0, max=255), html_validator])
    last_name = StringField(word('Last name'), [validators.Length(min=0, max=255), html_validator])
    country = StringField(word('Country code'), [validators.Length(min=0, max=2), html_validator])
    subdivisionfirst = StringField(word('First subdivision'), [validators.Length(min=0, max=64), html_validator])
    subdivisionsecond = StringField(word('Second subdivision'), [validators.Length(min=0, max=64), html_validator])
    subdivisionthird = StringField(word('Third subdivision'), [validators.Length(min=0, max=64), html_validator])
    organization = StringField(word('Organization'), [validators.Length(min=0, max=64), html_validator])
    language = StringField(word('Language'), [validators.Length(min=0, max=64), html_validator])
    timezone = SelectField(word('Time Zone'), [validators.Length(min=0, max=64), html_validator])
    pypi_username = StringField(word('PyPI Username'), [validators.Length(min=0, max=255), html_validator])
    email = StringField(word('E-mail'), validators=[Email(word('Must be a valid e-mail address')), html_validator])
    email = StringField(word('E-mail'), validators=[Optional(), Email(word('Must be a valid e-mail address')), html_validator])
    reason = StringField(word('Reason for needing developer account (optional)'), validators=[html_validator])
    first_name = StringField(word('First name'), [validators.Length(min=0, max=255), html_validator])
    last_name = StringField(word('Last name'), [validators.Length(min=0, max=255), html_validator])
    phone_number = StringField(word('Phone number'), [validators.Length(min=5, max=255), html_validator])
    phone_number = StringField(word('Phone number'), [validators.Length(min=5, max=255), html_validator])
    verification_code = StringField(word('Verification code'), [validators.Length(min=daconfig['verification code digits'], max=daconfig['verification code digits']), html_validator])
    phone_number = StringField(word('Phone number'), [validators.Length(min=5, max=255), html_validator])
        validators.Email(word('Invalid e-mail address'))
    ])
from bs4 import BeautifulSoup
from wtforms import ValidationError
from docassemble.base.functions import LazyWord as word


def html_validator(form, field):  # pylint: disable=unused-argument
    """Field must not contain HTML"""
    text = BeautifulSoup(field.data, "html.parser").get_text('')
    if text != field.data:
        raise ValidationError(word('Field cannot contain HTML'))