[wp-trac] Re: [WordPress Trac] #2990: Inline Upload Image Size
Attribute Problem For "Using Original"
WordPress Trac
wp-trac at lists.automattic.com
Sat Jan 6 12:46:13 GMT 2007
#2990: Inline Upload Image Size Attribute Problem For "Using Original"
----------------------------+-----------------------------------------------
Reporter: intoxination | Owner: anonymous
Type: defect | Status: reopened
Priority: high | Milestone: 2.0.7
Component: Administration | Version: 2.0.6
Severity: normal | Resolution:
Keywords: upload image |
----------------------------+-----------------------------------------------
Changes (by smalldust):
* priority: normal => high
* version: 2.0.4 => 2.0.6
* milestone: => 2.0.7
Comment:
I downloaded 2.0.6 today but still found this bug.
The root cause of this bug is, in line 434 of wp-admin/inline-upload.php
there is such a statement:
h = h.replace(new RegExp('
(class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)',
'g'), ' $1="$2"$3'); // Enclose attribs in quotes
which is supposed to be able to enclose all attributes in quotes.
But read it carefully, you will know it requires a blank char before the
attribute name, and also a blank or / or > after the value of the
attribute.
So when there are more than 1 attributes need to be enclosed here, eg
<img id=image01 height=90 .... >
because there is only 1 blank character between "id=image01" and
"height=90", and it will be eaten up when "id=image01" is matched. So,
"height=90" won't be matched because of the lack of blank character before
it.
To solve this problem, I suggest replace the aforementioned statement with
this one:
h = h.replace(new RegExp('
(class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)(?=(
|/|>))', 'g'), ' $1="$2"'); // Enclose attribs in quotes
In this statement, I use the lookahead pattern(?=) to exclude the
character after the value of attribute.
--
Ticket URL: <http://trac.wordpress.org/ticket/2990#comment:3>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list