Page MenuHomePhabricator

new parser function to convert relative path to absolute path
Closed, ResolvedPublic

Description

Don't remember with whom I had the discussion, but I have gone implementing the
abillity to soecify relative paths in #ifexist not (see following patch), It's
mostly based on Parser.php p. 1860 ff. but made some modifications that I felt
was good.


Version: unspecified
Severity: normal

Details

Reference
bz8021

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:28 PM
bzimport set Reference to bz8021.
bzimport added a subscriber: Unknown Object (MLST).

the implementation details

attachment ifexist-2.patch ignored as obsolete

robchur wrote:

That error message text is ridiculous.

(In reply to comment #2)

That error message text is ridiculous.

I didn't know what to write, so I wrote what first came into my mind. If you
have a better solution, please feel free to contribute.

robchur wrote:

"If in NS_MEDIA, check against actual file"

(In reply to comment #4)

"If in NS_MEDIA, check against actual file"

Thats not this issue I think. (this bug report is separate from the Image bug 7985)

robchur wrote:

Well, sort that one out as well, then. Try something like "Error: Invalid path"
or "Error: Invalid path depth".

(In reply to comment #6)

Well, sort that one out as well, then. Try something like "Error: Invalid path"
or "Error: Invalid path depth".

They are sorted out, they have nothing to do with each other.
I'll make the change to the error message.

implementation of the functionallity

As requested by Rob Church, I have changed the error message, also added some
extra whitespaces to the code and added some comments.

attachment ifexist-2.patch ignored as obsolete

reimplementation of the patch

I decided to totally rewamp the design, to be able to handle more strange path
constructs, like for example:
"../../Flubb/../Baz/../mamma/pappa/barn/../../mamma"

attachment ifexist-2.patch ignored as obsolete

robchur wrote:

Do we really need to support "strange path constructs" to this extent? There's
being flexible about it, and implementing it to a stupid level; we can
reasonably demand that users don't try to do fucked up things with this.

(In reply to comment #10)

Do we really need to support "strange path constructs" to this extent? There's
being flexible about it, and implementing it to a stupid level; we can
reasonably demand that users don't try to do fucked up things with this.

The cases I had in mind was "foo/../bar" and "foo/.."

robchur wrote:

Your example implied otherwise.

(In reply to comment #12)

Your example implied otherwise.

sorry, I just copied my test-string.

On a not, just thought it might be better to separate the code to a new function
{{#rel2abs:}} or simlar

the new patch

As I suggested to my self earlier, I decided to move the code to an new
function called 'rel2abs' that will return an absolute path from an relative
one. (Thus it can be used for more)

attachment ifexist-2.patch ignored as obsolete

the patch, updated minor

Just forgot to remove the level check in the while statement, as it's
unnecessary

attachment rel2abs.patch ignored as obsolete

the patch again

I was thinking a bit wrong there, we can't just count the number of levels, we
need to check that we won't go above root.

attachment rel2abs.patch ignored as obsolete

possibly final patch

changed the implementation to use push, pop and unshift instead.

attachment rel2abs.patch ignored as obsolete

the last patch

a bugfix only

attachment rel2abs.patch ignored as obsolete

ayg wrote:

Committed by Tim with substantial modification in r17979.

some minor modifications

sure I forgot something earlier

attachment rel2abs.patch ignored as obsolete

minor modifications

should probably trim $from first.

Attached: