Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

[BUG] Unescaped trailing backslash when replacing file separators on Windows #446

Open
4 of 6 tasks
martind260 opened this issue Oct 18, 2024 · 1 comment
Open
4 of 6 tasks

Comments

@martind260
Copy link

martind260 commented Oct 18, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request
Description

To determine ModuleLocation, replaceAll is used on File.separator, which is "" on Windows systems.
mystring.replaceAll(String.valueOf(File.separatorChar), ".")
replaceAll is expecting a regex to replace, but "" is a reserved character in regex. An error is thrown:
java.util.regex.PatternSyntaxException: Unescaped trailing backslash near index 1

If you just replace all occurrences of .replaceAll(String.valueOf(File.separatorChar) with replace(File.separatorChar, '.'), it will work.

openapi-json-schema-generator version

4.5.1

OpenAPI declaration file content or url
Generation Details
Steps to reproduce

Just execute: "test\test1\test2".replaceAll(String.valueOf(File.separatorChar), ".") on Windows

Related issues/PRs
Suggest a fix

Exchange replaceAll with replace

@spacether
Copy link
Contributor

Thanks for report. Would you like to submit a PR fixing this issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants