3 Commits

Author SHA1 Message Date
dillard 3fc8601344 Keep occ output brackets escaped through the formatters
The overtyping and from_ansi formatters unescape brackets before they
parse the text, so escaping them beforehand was not enough: literal
brackets were still read as formatting. Enable
unixFormattingEscapeBrackets so both formatters escape the text again
after parsing. Verified in the browser: Symfony's "[alias]" in
`occ list` stays in place, ANSI colors still work, and formatting in
the output text (colors, links) is no longer applied.

Bump the version to 0.4.4 so browsers load the new script.
2026-09-30 02:25:13 +02:00
dillard 635cdd4b24 Escape brackets in occ output before rendering
jQuery Terminal reads "[" and "]" as its own formatting syntax. occ
output was echoed as is, so literal brackets, such as Symfony's
"[alias]" in `occ list`, closed the color formatting of the next line
early and moved text to the wrong place. Text from the output, like a
display name, could also inject terminal formatting.

Escape the brackets in the text and keep the ANSI sequences, so the
colors still work.
2026-09-30 02:07:46 +02:00
dillard 76368f154e Add check-on-branch guard: HEAD's branch, not just its cleanliness
git archive HEAD packages whatever commit the checkout currently points to,
regardless of branch - check-clean-tree only guards uncommitted changes, not
HEAD being a feature branch, old tag, PR checkout, or detached HEAD entirely.
Wired into source/appstore/version alongside the existing guards.
Override via RELEASE_BRANCH=<branch> for an intentional non-main release.
2026-09-27 00:45:18 +02:00
3 changed files with 32 additions and 5 deletions
+16 -3
View File
@@ -134,14 +134,14 @@ check-app-name:
(echo "app_name is empty - is 'xpath' (libxml2-utils/perl-XML-XPath) installed?" >&2; exit 1)
.PHONY: source
source: check-app-name check-clean-tree
source: check-app-name check-clean-tree check-on-branch
rm -rf $(source_build_directory)
mkdir -p $(source_build_directory)
git archive --format=tar --prefix=$(app_name)/ HEAD | gzip > $(source_package_name).tar.gz
# Builds the source package for the app store, ignores php and js tests
.PHONY: appstore
appstore: check-app-name check-clean-tree
appstore: check-app-name check-clean-tree check-on-branch
rm -rf $(appstore_build_directory)
mkdir -p $(appstore_build_directory)
git archive --format=tar --prefix=$(app_name)/ HEAD | gzip > $(appstore_package_name).tar.gz
@@ -178,8 +178,21 @@ check-clean-tree:
@git diff --quiet HEAD -- || \
(echo "Uncommitted changes to tracked files - commit before releasing (see 'git status')." >&2; exit 1)
# `git archive HEAD` packages whatever commit the checkout currently points
# to, regardless of branch - check-clean-tree only guards against *uncommitted*
# changes, not against HEAD being the wrong branch entirely (a feature branch,
# an old tag, a PR checkout, a detached HEAD). Override for the rare
# intentional case (e.g. releasing from a branch on purpose):
# make appstore RELEASE_BRANCH=some-branch
RELEASE_BRANCH ?= main
.PHONY: check-on-branch
check-on-branch:
@test "$$(git rev-parse --abbrev-ref HEAD)" = "$(RELEASE_BRANCH)" || \
(echo "HEAD is on '$$(git rev-parse --abbrev-ref HEAD)', not '$(RELEASE_BRANCH)' - pass RELEASE_BRANCH=<branch> to override if this is intentional." >&2; exit 1)
.PHONY: version
version: check-clean-tree
version: check-clean-tree check-on-branch
@echo "Creating version v$(VERSION)"
@git tag v$(VERSION)
@git push $(RELEASE_REMOTE) v$(VERSION)
+1 -1
View File
@@ -5,7 +5,7 @@
<name>Extended OCC Web</name>
<summary>OCC Commands in a web terminal</summary>
<description><![CDATA[Run OCC Commands in a web terminal]]></description>
<version>0.4.3</version>
<version>0.4.4</version>
<licence>agpl</licence>
<author mail="dillard.blom@ensembia.com" >Dillard Blom</author>
<namespace>OCCWeb</namespace>
+15 -1
View File
@@ -14,6 +14,17 @@
}
var baseUrl = OC.generateUrl('/apps/extended_occweb');
// occ output is plain text with ANSI colors, but jQuery Terminal reads
// "[" and "]" as its own formatting syntax. Escape the brackets in the
// text (e.g. Symfony's "[alias]" in `occ list`) and leave the ANSI
// sequences alone, so from_ansi can still turn them into colors. This
// only works together with unixFormattingEscapeBrackets (see below).
function escapeOutputBrackets(output) {
return String(output).replace(/(\x1B\[[0-9;]*[A-Za-z])|[\[\]]/g, function (match, ansi) {
return ansi ? ansi : (match === '[' ? '&#91;' : '&#93;');
});
}
// Current terminal mode: 'occ' (regular occ commands) or 'sql'
// (running arbitrary SQL queries via /db/query).
var mode = 'occ';
@@ -386,7 +397,7 @@
headers: { requesttoken: OC.requestToken },
data: JSON.stringify(occCommand)
}).done(function (response) {
term.echo('\n' + response).resume();
term.echo('\n' + escapeOutputBrackets(response)).resume();
}).fail(function (xhr, status) {
term.echo('\n[[;#ff5555;]Request failed: ]' + $.terminal.escape_formatting(xhr.status + ' ' + xhr.statusText)).resume();
});
@@ -398,6 +409,9 @@
name: 'occ',
prompt: OCC_PROMPT,
completion: response,
// The overtyping and from_ansi formatters unescape brackets before
// parsing; this makes them escape the text again afterwards.
unixFormattingEscapeBrackets: true,
keydown: function (e) {
// Shift+Enter inserts a newline instead of running the command,
// letting you type multi-line SQL scripts in sql mode.