-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defuse sia title characters #557
Conversation
0afc840
to
036a789
Compare
This is intended to fix bug astropy#556.
Rebased to resolve conflicts, and also removed the commit from the other PR as it has been merged already. |
036a789
to
12f6f63
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests need to be fixed for windows, for which I pushed a commit, otherwise this looks good to me.
Thank you!
Same as for #553, I change the milestone for the bugfix, if that comes out sooner than 1.6 |
@@ -894,6 +894,9 @@ def make_dataset_filename(self, *, dir=".", base=None, ext=None): | |||
if not ext: | |||
ext = self.suggest_extension(default="dat") | |||
|
|||
base = base.replace("/", "_" | |||
).replace("\\", "_") | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I would replace each
\
with_
to correctly keep track of the replacements. Single\
might also create issues. - I've noticed that
suggest_dataset_basename
fixes empty spaces too but this is not the case ifbase
is present. Should we do this sanitization in one place (and potentially add more rules to it over time)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, I'm sorry for the premature merge then.
On Thu, Jun 27, 2024 at 02:42:24PM -0700, Adrian wrote:
1. I would replace each `\` with `_` to correctly keep track of the
replacements. Single `\` might also create issues.
This is what already happens here; '\\' is the literal for a single
backslash.
2. I've noticed that `suggest_dataset_basename` fixes empty spaces
too but this is not the case if `base` is present. Should we do
this sanitization in one place (and potentially add more rules to
it over time)?
Hm... I'm not even sure whether I think replacing whitespace is a good
idea in the first place; I think even ancient FAT would support that,
and as to requiring quoting in common shells... Well, if we wanted to
make sure you get away without that, we'd have to do a lot more
mangling.
Anyway, I think that's a separate issue from repairing cachedataset()
for image titles with (back-)slashes. I give you that refactoring
suggest_dataset_basename (which has fairly parallel implementations
in ssap and sia on top) might be an improvement, and something that
produces filenames good across many platforms in a central place
sounds like a good idea, too (where we'd have to discuss whether we'd
want to limit the charset to ASCII printables...). What about filing
a bug?
|
Issue #573 - please feel free to add or change the details. |
This is intended as a fix for bug #556. To keep things simple, I'm basing this on the branch of PR #553, because this plays in the vicinity of its code.
As mentioned in the commit message, one might argue we should lock down the file names more strongly than that. I'd be open to that, but only if people actually feel there is a sufficient need for that.
fixes #556