Last Comment Bug 682166 - Allow absolute pathnames in js console read()
: Allow absolute pathnames in js console read()
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: All Linux
: -- normal (vote)
: mozilla9
Assigned To: Alon Zakai (:azakai)
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-25 17:38 PDT by Alon Zakai (:azakai)
Modified: 2011-09-01 01:46 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch (409 bytes, patch)
2011-08-25 17:38 PDT, Alon Zakai (:azakai)
no flags Details | Diff | Splinter Review
patch with context (586 bytes, patch)
2011-08-25 17:40 PDT, Alon Zakai (:azakai)
cdleary: review+
Details | Diff | Splinter Review

Description Alon Zakai (:azakai) 2011-08-25 17:38:01 PDT
Created attachment 555902 [details] [diff] [review]
patch

Currently the js console, when told to

  read('/usr/share/...')

will try to read

  CURRENT_DIR//user/share

(and fail) since it appends the parameter to the current directory.

Attached is a patch that leaves absolute pathnames (starting with '/') alone. For comparison, v8 does that.
Comment 1 Alon Zakai (:azakai) 2011-08-25 17:40:25 PDT
Created attachment 555903 [details] [diff] [review]
patch with context

(forgot -U 8, sorry)
Comment 2 Chris Leary [:cdleary] (not checking bugmail) 2011-08-25 19:09:09 PDT
Comment on attachment 555903 [details] [diff] [review]
patch with context

Review of attachment 555903 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/shell/js.cpp
@@ +3805,5 @@
>  
> +    if (*leaf == '/') {
> +        /* We were given an absolute pathname. */
> +        return JS_strdup(cx, leaf);
> +    }

Do we want to wrap this in an |#if !defined(XP_WIN)|?
Comment 3 Alon Zakai (:azakai) 2011-08-25 19:54:26 PDT
MakeAbsolutePathname is actually only defined and used ifdef XP_UNIX. I guess no one uses the shell on Windows ;)
Comment 5 Ed Morley [:emorley] 2011-09-01 01:46:46 PDT
http://hg.mozilla.org/mozilla-central/rev/5a7e488482a5

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