Skip to content

Sniff encoding properly in XML files with a standalone directive#256

Merged
asnare merged 2 commits intomainfrom
handle-xml-standalone
Jul 30, 2025
Merged

Sniff encoding properly in XML files with a standalone directive#256
asnare merged 2 commits intomainfrom
handle-xml-standalone

Conversation

@asnare
Copy link
Copy Markdown
Contributor

@asnare asnare commented Jul 22, 2025

This PR updates the code that detects the encoding of XML files so that it correctly detects the encoding= attribute if there is also a standalone= directive. Previously we only supported XML directives of the form:

<?xml version="1.x" encoding="xxx"?>

However the XML declaration may also contain a standalone= attribute. If present we previously failed to detect the encoding attribute, but now we also support XML directives of the form:

<?xml version="1.x" encoding="xxx" standalone="yes"?>

@asnare asnare self-assigned this Jul 22, 2025
@asnare asnare requested a review from nfx as a code owner July 22, 2025 09:38
@asnare asnare added the bug Something isn't working label Jul 22, 2025
@asnare asnare requested review from gueniai and sundarshankar89 and removed request for nfx July 22, 2025 09:39
@github-actions
Copy link
Copy Markdown

✅ 40/40 passed, 2 skipped, 1m44s total

Running from acceptance #342

Copy link
Copy Markdown

@jimidle jimidle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@asnare asnare merged commit bb2541c into main Jul 30, 2025
11 checks passed
@asnare asnare deleted the handle-xml-standalone branch July 30, 2025 15:29
sundarshankar89 added a commit that referenced this pull request Oct 6, 2025
* Added Password Prompt to operate with echo off in terminal ([#265](#265)). The command-line interface now includes a secure password prompt feature, allowing users to enter sensitive information without it being visible on the screen. This is achieved through a new method that utilizes the `getpass` library to hide user input when entering passwords, taking a prompt message and an optional maximum number of attempts as parameters. The method repeatedly prompts the user for a password until a valid input is provided or the maximum number of attempts is reached, at which point it raises a `ValueError`. This addition enhances the security and usability of the interface, and its functionality is validated through new test methods that cover both successful password entry and the scenario where the maximum number of attempts is exceeded, ensuring the feature behaves as expected in various situations.
* Sniff encoding properly in XML files with a standalone directive ([#256](#256)). The XML file encoding detection has been improved to support a wider range of valid XML declarations. The regular expression used to match XML declarations has been updated to correctly handle cases where both `encoding` and `standalone` attributes are present, such as `<?xml version="1.x" encoding="xxx" standalone="yes"?>`. This change enables more accurate detection of the encoding attribute in XML files, even when a `standalone` directive is present. Additionally, test functions have been added and modified to verify this functionality, including tests for XML files with a BOM prefix and those with an XML standalone declaration, ensuring that the code can correctly read these files and detect the encoding.
@sundarshankar89 sundarshankar89 mentioned this pull request Oct 6, 2025
sundarshankar89 added a commit that referenced this pull request Oct 6, 2025
* Added Password Prompt to operate with echo off in terminal
([#265](#265)). The
command-line interface now includes a secure password prompt feature,
allowing users to enter sensitive information without it being visible
on the screen. This is achieved through a new method that utilizes the
`getpass` library to hide user input when entering passwords, taking a
prompt message and an optional maximum number of attempts as parameters.
The method repeatedly prompts the user for a password until a valid
input is provided or the maximum number of attempts is reached, at which
point it raises a `ValueError`. This addition enhances the security and
usability of the interface, and its functionality is validated through
new test methods that cover both successful password entry and the
scenario where the maximum number of attempts is exceeded, ensuring the
feature behaves as expected in various situations.
* Sniff encoding properly in XML files with a standalone directive
([#256](#256)). The
XML file encoding detection has been improved to support a wider range
of valid XML declarations. The regular expression used to match XML
declarations has been updated to correctly handle cases where both
`encoding` and `standalone` attributes are present, such as `<?xml
version="1.x" encoding="xxx" standalone="yes"?>`. This change enables
more accurate detection of the encoding attribute in XML files, even
when a `standalone` directive is present. Additionally, test functions
have been added and modified to verify this functionality, including
tests for XML files with a BOM prefix and those with an XML standalone
declaration, ensuring that the code can correctly read these files and
detect the encoding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants