Escaping double quotes in plaintext secret in csv upload #3132

Closed
opened 2025-12-29 18:25:59 +01:00 by adam · 2 comments
Owner

Originally created by @EugeniaWong on GitHub (Jan 8, 2020).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.5.6

Proposed Functionality

To allow the use of double quotes in secrets. At the moment, double quotes cannot be part of a plaintext secret as they are used to wrap multi-line data nad values containing commas.

Use Case

To allow the use of double quotes in secrets.

Database Changes

External Dependencies

Originally created by @EugeniaWong on GitHub (Jan 8, 2020). <!-- NOTE: This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.5.2 * NetBox version: 2.5.6 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality To allow the use of double quotes in secrets. At the moment, double quotes cannot be part of a plaintext secret as they are used to wrap multi-line data nad values containing commas. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case To allow the use of double quotes in secrets. <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies
adam closed this issue 2025-12-29 18:25:59 +01:00
Author
Owner

@hSaria commented on GitHub (Jan 8, 2020):

As with Excel CSVs, you can put double-quotes in your data by replacing it with a pair of double-quotes.

For example, here are two secrets.

name,device,role,plaintext
secret1,as-01,bla,"hello""world"
secret2,as-01,bla,"hello
""
world"

They are represented in JSON (i.e. the API) as:

"plaintext": "hello\"world"
"plaintext": "hello\r\n\"\r\nworld"
@hSaria commented on GitHub (Jan 8, 2020): As with Excel CSVs, you can put double-quotes in your data by replacing it with **a pair of double-quotes**. For example, here are two secrets. ``` name,device,role,plaintext secret1,as-01,bla,"hello""world" secret2,as-01,bla,"hello "" world" ``` They are represented in JSON (i.e. the API) as: ```json "plaintext": "hello\"world" "plaintext": "hello\r\n\"\r\nworld" ```
Author
Owner

@jeremystretch commented on GitHub (Jan 9, 2020):

FYI this is a function of Python's csv library. From the docs:

Dialect.doublequote
Controls how instances of quotechar appearing inside a field should themselves be quoted. When True, the character is doubled. When False, the escapechar is used as a prefix to the quotechar. It defaults to True.

@jeremystretch commented on GitHub (Jan 9, 2020): FYI this is a function of Python's `csv` library. From [the docs](https://docs.python.org/3.6/library/csv.html#csv.Dialect.doublequote): > **Dialect.doublequote** > Controls how instances of quotechar appearing inside a field should themselves be quoted. When True, the character is doubled. When False, the escapechar is used as a prefix to the quotechar. It defaults to True.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3132