Skip to content

Fix ReplaceSpecialCharacters() silently dropping its dot-collapse step - #48

Open
vertesy wants to merge 2 commits into
devfrom
fix-replacespecialcharacters-dot-collapse
Open

Fix ReplaceSpecialCharacters() silently dropping its dot-collapse step#48
vertesy wants to merge 2 commits into
devfrom
fix-replacespecialcharacters-dot-collapse

Conversation

@vertesy

@vertesy vertesy commented Aug 28, 2026

Copy link
Copy Markdown
Owner

The bug

The function computed ReplaceRepeatedDots(x) as its second-to-last statement but never assigned the result back to x — it was a bare expression, so R discarded it. The actual return value came from the final if (remove_dots) x <- gsub(...) else x line, which still operated on the un-collapsed x.

Impact

A direct call to ReplaceSpecialCharacters() on a string with adjacent special characters returns runs of repeated dots instead of a single collapsed dot, e.g. ReplaceSpecialCharacters("a[[b]]") returned "a..b.." instead of "a.b." (verified before/after). Most existing call sites (FixPlotName(), ParseFullFilePath()) were unaffected in practice, because they each independently call ReplaceRepeatedDots() again on the result afterward and so already compensated for this — but any code calling ReplaceSpecialCharacters() directly got the uncollapsed output.

Fix

Assign the result (x <- ReplaceRepeatedDots(x)) so the collapse step actually applies before the optional remove_dots step.

Version bumped 1.2.1 → 1.2.2 in Development/config.R and DESCRIPTION.

Validation

Manually confirmed direct calls now collapse dots correctly while FixPlotName()/ParseFullFilePath() output is unchanged (as expected, since they already compensated). R CMD check and the existing testthat suite (7/7 passing) were run on this branch. Remaining R CMD check findings (parFlags example error, parsepvalue undocumented prefix, %!in% Rd-name warning, sandbox locale warning) are pre-existing and out of scope, addressed in other PRs in this batch or environment-inherent.


Generated by Claude Code

claude added 2 commits August 27, 2026 21:23
The function computed ReplaceRepeatedDots(x) as its second-to-last
statement but never assigned the result back to `x` - it was a bare
expression, so R discarded it. The actual return value came from the
final `if (remove_dots) x <- gsub(...) else x` line, which still
operated on the un-collapsed `x`.

Impact: a direct call to ReplaceSpecialCharacters() on a string with
adjacent special characters returns runs of repeated dots instead of a
single collapsed dot, e.g. ReplaceSpecialCharacters("a[[b]]") returned
"a..b.." instead of "a.b.". Most existing call sites (FixPlotName(),
ParseFullFilePath()) were unaffected in practice, because they each
independently call ReplaceRepeatedDots() again on the result afterward
and so already compensated for this - but any code calling
ReplaceSpecialCharacters() directly got the uncollapsed output.

Fix: assign the result (`x <- ReplaceRepeatedDots(x)`) so the collapse
step actually applies before the optional remove_dots step.

Version bumped 1.2.1 -> 1.2.2 in Development/config.R and DESCRIPTION.

Validation: manually confirmed direct calls now collapse dots correctly
while FixPlotName()/ParseFullFilePath() output is unchanged (as
expected, since they already compensated). R CMD check and the existing
testthat suite (7/7 passing) were run on this branch. Remaining R CMD
check findings (parFlags example error, parsepvalue undocumented
prefix, %!in% Rd name warning, sandbox locale warning) are pre-existing
and out of scope, addressed in other PRs in this batch or
environment-inherent.
…acters-dot-collapse

# Conflicts:
#	DESCRIPTION
#	Development/config.R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants