Bug 67154 - UIWebView: Inconsistent Regular Expression Processing
Summary: UIWebView: Inconsistent Regular Expression Processing
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other Other
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-08-29 14:31 PDT by mdakin
Modified: 2012-03-11 14:48 PDT (History)
4 users (show)

See Also:


Attachments
Contains test HTML and Screenshots of output. (97.26 KB, application/zip)
2011-08-29 14:31 PDT, mdakin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description mdakin 2011-08-29 14:31:01 PDT
Created attachment 105522 [details]
Contains test HTML and Screenshots of output.

Elias Zamaria has discovered a bug in the regular-expression processing of the webkit that runs inside the UIWebView on an iPhone 4 running iOS 4.3.3 (8J2).  The user-agent string of such a UIWebView is:

Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8J2

The bug presents in the following manner:

iOS 4.3.3 UIWebView: PRESENTS: iOS-4_3_3-UIWebView.png
iOS 4.3.3 Safari: DOES NOT PRESENT: iOS-4_3_3-Safari.png
MacOS Safari 5.1 (6534.50): DOES NOT PRESENT: MacOS-Safari-5_1.jpg

We believe the iOS 4.3.3 UIWebView case to be INCORRECT output.  Whereas the other cases are correct.

Steps to reproduce:

Load http://eliasz.net/regexTest.html using a UIWebView.

Alternatively, regexTest.html can be found in the zipfile attached to this bug.

To be explicit, the test code is this:

<!DOCTYPE html>
<html><head>
<title>regex test</title>
</head>
<body>
<div id="test"></div>
<script>document.getElementById("test").innerText = "stuff/oldSubstr".replace(/[^\/]*?$/, "replacement");</script>
</body></html>

It is expected that "oldSubstr" be replaced with "replacement."  This does not happen in the UIWebView case (the replacement string is instead appended to the end).

All of the above-mentioned files have all been incorporated into the attached regexTest.zip.

Could this bug be related to:

https://bugs.webkit.org/show_bug.cgi?id=23121

?
Comment 1 Alexey Proskuryakov 2011-08-29 15:37:05 PDT
Please don't report iOS specific bugs here, http://bugreport.apple.com is the correct place for that.
Comment 2 Geoffrey Garen 2011-08-29 18:51:53 PDT
Even though this report is ostensibly about UIWebView, I suspect it comes down to a bug in JavaScriptCore's regular expression interpreter. My guess is that the same bug is reproducible on PPC in Safari, too, or if you modify the expression to add complex capturing. 

Anyone out there have a PPC box they can test with? :)
Comment 3 Geoffrey Garen 2011-08-29 18:57:43 PDT
<rdar://problem/10043693>
Comment 4 Gavin Barraclough 2012-03-11 14:48:27 PDT
This bug should be fixed in iOS 5.0 or later, please reopen if you can still reproduce this issue.

thanks!, G.