Skip to content

Commit

Permalink
ignore _aitranslate_bak in recursive translation
Browse files Browse the repository at this point in the history
  • Loading branch information
stoerr committed Nov 13, 2024
1 parent 68bd8d0 commit 114e3a0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ protected void copyOriginalPage(SlingHttpServletRequest request, String path) th
}
Page copy = pageManager.copy(originalPage, newPath, null, true, true, false);
if (copy != null) {
liveRelationshipManager.endRelationship(copy.getContentResource(), false);
liveRelationshipManager.endRelationship(copy.getContentResource(), true);
liveRelationshipManager.detach(copy.getContentResource(), true); // end doesn't seem to work
LOG.info("Created copy of {} at {}", originalPage.getPath(), newPath);
resolver.commit();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public TranslationRun startTranslation(
}

protected List<Resource> collectPages(Resource root, int maxDepth) {
if (maxDepth < 0) {
if (maxDepth < 0 || root.getName().endsWith(AutoTranslateListModel.SUFFIX_TRANSLATECOPY)) {
return Collections.emptyList();
}
if (root.getPath().contains("/jcr:content")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.adobe.granite.workflow.metadata.MetaDataMap;
import com.composum.ai.aem.core.impl.autotranslate.AutoPageTranslateService;
import com.composum.ai.aem.core.impl.autotranslate.AutoTranslateConfigService;
import com.composum.ai.aem.core.impl.autotranslate.AutoTranslateListModel;
import com.composum.ai.aem.core.impl.autotranslate.AutoTranslateService.TranslationParameters;
import com.day.cq.wcm.api.WCMException;
import com.google.gson.Gson;
Expand Down Expand Up @@ -146,7 +147,8 @@ protected void translate(@Nonnull Resource resource, TranslationParameters parms
while (childIterator.hasNext()) {
Resource child = childIterator.next();
// skip jcr:content node since that has been translated already
if (!child.getPath().contains("/jcr:content")) {
if (!child.getPath().contains("/jcr:content") &&
!child.getName().endsWith(AutoTranslateListModel.SUFFIX_TRANSLATECOPY)) {
translate(child, parms, depth + 1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
</section>
<hr>
<section>
Drag this bookmarklet to your bookmark bar to easily open this UI from any page:
Drag this bookmarklet to your bookmark bar to easily open this UI with the path from any page or editor:
<a id="bookmarklet">Translation Tester</a>
</section>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,14 @@
// Load the initial URLs if available in the parameters
const initialUrl1 = getParameterByName('url1');
const initialUrl2 = getParameterByName('url2');
if (initialUrl1) leftIframe.src = initialUrl1;
if (initialUrl2) rightIframe.src = initialUrl2;
if (initialUrl1) {
leftIframe.src = initialUrl1;

Check failure

Code scanning / CodeQL

Client-side cross-site scripting High

Cross-site scripting vulnerability due to
user-provided value
.
leftField.value = initialUrl1;
}
if (initialUrl2) {
rightIframe.src = initialUrl2;

Check failure

Code scanning / CodeQL

Client-side cross-site scripting High

Cross-site scripting vulnerability due to
user-provided value
.
rightField.value = initialUrl2;
}

// Load event listeners for iframes
leftIframe.addEventListener('load', function () {
Expand Down

0 comments on commit 114e3a0

Please sign in to comment.