Skip to content

Commit 29f171d

Browse files
authored
Fix issues with parsing ampersands (#80)
1 parent c5062d4 commit 29f171d

File tree

4 files changed

+3
-23
lines changed

4 files changed

+3
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ poEditor {
4848
```
4949

5050
</details>
51+
5152
### Changed
5253
- Refactor the whole parsing logic to better handle input and improve performance.
5354
### Deprecated
5455
- No deprecated features!
5556
### Removed
5657
- No removed features!
5758
### Fixed
58-
- No fixed issues!
59+
- Fix bug with `&` character not being properly escaped.
5960
### Security
6061
- No security issues fixed!
6162

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Attribute | Description
123123
```resFileName``` | (Since 3.1.0) (Optional) Sets the file name for the imported string resource XML files. Defaults to `strings`.
124124
```order``` | (Since 3.1.0) (Optional) Defines how to order the export. Accepted values are defined by the POEditor API.
125125
```unquoted``` | (Since 3.2.0) (Optional) Defines if the strings should be unquoted, overriding default PoEditor configuration. Defaults to `false`.
126-
```unescapeHtmlTags``` | (Since 3.4.0) (Optional) Whether or not to unescape HTML entitites from strings. Defaults to `true`.
126+
```unescapeHtmlTags``` | (Since 3.4.0) (Optional) Whether or not to unescape HTML tags (`<`, `>`) from strings. Defaults to `true`.
127127
```untranslatableStringsRegex``` | (Since 4.2.0) (Optional) Pattern to use to mark strings as translatable=false in the strings file. Defaults to `null`.
128128
```includeComments``` | (Since 5.0.0) (Optional) Whether to include comments from the downloaded strings. Defaults to `true`.
129129

src/main/kotlin/com/hyperdevs/poeditor/gradle/extensions/StringExtensions.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ private val cdataRegex = Regex("^<!\\[CDATA\\[(.*)]]>$", RegexOption.DOT_MATCHES
2626
fun String.unescapeHtmlTags() = this
2727
.replace("&lt;", "<")
2828
.replace("&gt;", ">")
29-
.replace("&amp;", "&")
30-
.replace("&apos;", "'")
31-
.replace("&quot;", "\"")
3229

3330
/**
3431
* Returns if the given string is a CDATA string.

src/test/kotlin/com/hyperdevs/poeditor/gradle/xml/StringsXmlPostProcessorTest.kt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -431,24 +431,6 @@ class StringsXmlPostProcessorTest {
431431
assertEquals(expectedResult, StringsXmlPostProcessor.formatTranslationXml(inputStringsXmlDocument, true, null, true))
432432
}
433433

434-
@Test
435-
fun `Postprocessing XML with string HTML symbols works 2`() {
436-
// Test complete Xml
437-
val inputStringsXmlDocument = StringsXmlDocument(
438-
resources = listOf(
439-
StringsXmlResource.StringElement("hello_friend_bold", "&amp;lt;b&amp;gt;Hello world&amp;lt;/b&amp;gt;")
440-
)
441-
)
442-
443-
val expectedResult = StringsXmlDocument(
444-
resources = listOf(
445-
StringsXmlResource.StringElement("hello_friend_bold", "&lt;b&gt;Hello world&lt;/b&gt;")
446-
)
447-
)
448-
449-
assertEquals(expectedResult, StringsXmlPostProcessor.formatTranslationXml(inputStringsXmlDocument, true, null, true))
450-
}
451-
452434
@Test
453435
fun `Postprocessing XML with string HTML symbols and unescape set to false works`() {
454436
// Test complete Xml

0 commit comments

Comments
 (0)