Skip to content

kwargs are not checked for unexpected parameters #1238

Open
@timmc

Description

@timmc
  • Repro case: return markdown.markdown(post, output='html5')
  • Expected behavior: Error or warning
  • Actual behavior: Typo is ignored

For a while I had the code return markdown.markdown(post, output='html5'), which seemed to be working OK. However, it turns out that was a typo -- I should have been using output_format. Normally, the runtime would catch this, but instead **kwargs are collected and passed to the Markdown class, where keys are retrieved as needed.

It's not a security issue in this library, as far as I can tell, but this pattern has lead to security issues elsewhere. (Imagine if there were a safe_output kwarg that someone typo'd.)

I think this could be as simple as having a known-keys set that the kwargs dict's keys are checked against before processing. I'd be happy to contribute a PR if this would be an acceptable approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRelated to the core parser code.featureFeature request.needs-decisionA decision needs to be made regarding request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions