Bug 1024381 - windows paths with '\' as delimiter are not used correctly. '\' is omited
Summary: windows paths with '\' as delimiter are not used correctly. '\' is omited
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: CLI
Version: 6.2.0
Hardware: Unspecified
OS: Windows
unspecified
high
Target Milestone: ---
: ---
Assignee: Alexey Loubyansky
QA Contact: Petr Kremensky
Russell Dickenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-29 14:39 UTC by Martin Simka
Modified: 2016-04-29 07:16 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-12-17 13:26:19 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1056933 0 unspecified CLOSED [GSS] (6.4) CLI incorrectly parses backslashes in commands 2021-02-22 00:41:40 UTC

Internal Links: 1056933

Description Martin Simka 2013-10-29 14:39:44 UTC
Description of problem:
##################
windows paths with '\' as delimiter are not used correctly. '\' is omited 

Steps to Reproduce:
##################
Try to add log handler:
/profile=default/subsystem=logging/size-rotating-file-handler=test:add(file={path="w:\test\test.log"})

and read-attribute
[domain@localhost:9999 /] /profile=default/subsystem=logging/size-rotating-file-handler=test:read-attribute(name=file)
INFO  [org.jboss.as.cli.CommandContext] {
    "outcome" => "success",
    "result" => {"path" => "w:testtest.log"}
}
{
    "outcome" => "success",
    "result" => {"path" => "w:testtest.log"}
}

the same behaviour while setting java-home
[domain@localhost:9999 /] /host=master/server-config=server-AA/jvm=oraclejdk6:write-attribute(name=java-home, value="t:\opt\windows\a
md64\jdk1.6.0_last")

and read-attribute
[domain@localhost:9999 /] /host=master/server-config=server-AA/jvm=oraclejdk6:read-attribute(name=java-home)
INFO  [org.jboss.as.cli.CommandContext] {
    "outcome" => "success",
    "result" => "t:optwindowsamd64jdk1.6.0_last"
}
{
    "outcome" => "success",
    "result" => "t:optwindowsamd64jdk1.6.0_last"
}

When I try to escape \:
/host=master/server-config=server-AA/jvm=oraclejdk6:write-attribute(name=java-home, value="t:\\opt\windows\\amd64\\jdk1.6.0_last")

[domain@localhost:9999 /] /host=master/server-config=server-AA/jvm=oraclejdk6:read-attribute(name=java-home)
INFO  [org.jboss.as.cli.CommandContext] {
    "outcome" => "success",
    "result" => "t:\\optwindows\\amd64\\jdk1.6.0_last"
}
{
    "outcome" => "success",
    "result" => "t:\\optwindows\\amd64\\jdk1.6.0_last"
}

Comment 1 Martin Simka 2013-10-30 07:57:47 UTC
@Alexey: I set component to Domain Management because it behaves similarly in web console. Should I create new BZ for webconsole or your fix will solve both issues?

Comment 2 Alexey Loubyansky 2013-10-30 11:16:40 UTC
Really? Ok, the web console should check what's going on there too then. I just tested it quickly and it seemed like a CLI issue, although what I saw was a bit different:

[domain@localhost:9990 /] echo-dmr /profile=default/subsystem=logging/size-rotating-file-handler=test:add(file={path="w:\\test\\test.log"})
{
    "address" => [
        ("profile" => "default"),
        ("subsystem" => "logging"),
        ("size-rotating-file-handler" => "test")
    ],
    "operation" => "add",
    "file" => {"path" => "w:\\\\test\\\\test.log"}
}
[domain@localhost:9990 /] echo-dmr /profile=default/subsystem=logging/size-rotating-file-handler=test:add(file={path="w:\test\test.log"})
{
    "address" => [
        ("profile" => "default"),
        ("subsystem" => "logging"),
        ("size-rotating-file-handler" => "test")
    ],
    "operation" => "add",
    "file" => {"path" => "w:testtest.log"}
}

The read-attribute would return the values sent in the add request.

Comment 3 Alexey Loubyansky 2013-11-06 16:36:09 UTC
Ok, so if you don't see what I posted in the previous comment then it's not a bug. The back slash character has to be escaped. The result of the read-attribute operation that you see is in the DMR toString() format, which escapes the back slash character. If you try to get the actual value by calling asString() on the value instead of toString(), you'll see the value you expect. You can see it yourself using the read-attribute command. Here is what I mean:

[standalone@localhost:9990 /] /system-property=test:add(value="t:\\opt\windows\\amd64\\jdk1.6.0_last")
{"outcome" => "success"}
[standalone@localhost:9990 /] /system-property=test:read-attribute(name=value)
name="value"
{
    "outcome" => "success",
    "result" => "t:\\optwindows\\amd64\\jdk1.6.0_last"
}
[standalone@localhost:9990 /] read-attribute --node=system-property=test value
t:\optwindows\amd64\jdk1.6.0_last
[standalone@localhost:9990 /]

I took time to investigate what's going with the current master and why I saw what I posted in the previous comment. I'm gonna fix it. But your original description is the expected behavior.

Comment 4 Martin Simka 2013-11-11 09:56:06 UTC
Actually I don't understand why backslash character has to be escaped, I wouldn't expect it, especially if the whole path is enclosed in quotes. I'm not forced to escape backslash when using deploy command. 

e.g. 
deploy h:\hudson\users-tmp\msimka\tmp\TestWebApp-1.0-SNAPSHOT.war --all-server-groups

It's confusing.

Comment 5 Alexey Loubyansky 2013-11-11 14:10:55 UTC
The backslash character has to be escaped for the same reason it is escaped in Java strings. There are special characters in the operation request format. If a parameter value contains special characters, to not confuse the parser, these characters have to be escaped.

The path argument of the deploy command is different in that, the file system path is expected here, so the parsing of this value can be specialized for that.

You are using an operation request format, the only thing CLI knows about the argument is its value is of type STRING, which can be anything. There is no DMR type FILESYSTEM_PATH.

Comment 6 Alexey Loubyansky 2013-11-11 14:14:49 UTC
Or was your question about escaping in logging the result? In that case, use the read-attribute command (which prints the unescaped value) instead of the :read-attribute operation (which prints it raw as a raw DMR toString()).

Comment 7 Alexey Loubyansky 2013-11-11 14:17:49 UTC
Also see my last comment on https://bugzilla.redhat.com/show_bug.cgi?id=1020510 which explains how the values are parsed (quoted and unquoted among them).

Comment 8 Martin Simka 2013-11-11 14:33:57 UTC
Thanks for explanations. Perhaps it wouldn't be bad to have DMR type for file system paths in future releases. It may allow to have path autocompletion on more places.

Comment 9 Alexey Loubyansky 2013-12-17 13:26:19 UTC
As explained above, this is not a bug.


Note You need to log in before you can comment on or make changes to this bug.